Title: Marketplace upgrades leave full git clones
Open 💬 5 comments Opened Jun 25, 2026 by Nod1l
What issue are you seeing?
Bug: Each marketplace "upgrade" of a git-sourced marketplace clones the
full repo (incl. .git history) into ~/.codex/.tmp/marketplaces/.staging/
marketplace-upgrade-XXXX, but the staging dir is never deleted after promotion.
Impact: Accumulated 1784 leftover clones = 277 GB on C: over ~3 days.
Only the single git marketplace (claude-mem) was affected; local marketplaces
don't clone. Each clone = 171 MB, of which 158 MB is .git history.
Two issues:
- Staging temp not cleaned up after upgrade.
- Full clone instead of shallow (--depth 1) re-downloads entire git history
every refresh.
Env: Codex CLI app version 26.616.71553, Windows 11.
High session churn (automated runs) multiplies the leak.
Workaround: manually delete ~/.codex/.tmp/marketplaces/.staging
### What steps can reproduce the bug?
## Steps to reproduce
1. Configure a git-sourced marketplace in ~/.codex/config.toml:
[marketplaces.example]
source_type = "git"
source = "https://github.com/thedotmack/claude-mem.git"
2. Trigger a marketplace upgrade/refresh repeatedly (happens on session
start; automated/looping sessions trigger it many times).
3. Inspect ~/.codex/.tmp/marketplaces/.staging/ — a new
`marketplace-upgrade-XXXXXX` dir is created per upgrade.
4. After the upgrade completes, the staging dir is NOT deleted. Each one
is a full clone (~171 MB; ~158 MB is .git history).
5. Over many upgrades they accumulate without cleanup.
## Observed
1784 leftover `marketplace-upgrade-*` dirs = 277 GB on C:, accumulated over
~3 days. Only the single git marketplace was affected (local marketplaces
don't clone).
## Note
Root cause inferred from the 1784 leftover clones + config (not captured
live). Two defects: (1) staging temp never cleaned after promote;
(2) full clone instead of shallow (--depth 1) re-downloads entire git
history every refresh.
## Env
Codex CLI app version 26.616.71553, Windows 11.
### What is the expected behavior?
1. After a marketplace upgrade is promoted, the temporary staging directory
(~/.codex/.tmp/marketplaces/.staging/marketplace-upgrade-XXXXXX) is
deleted automatically. No leftovers remain.
2. Stale or failed staging directories are cleaned up on the next startup,
so they cannot accumulate across sessions.
3. Git-sourced marketplaces are fetched with a shallow clone (--depth 1)
and/or updated in place (git fetch/pull on a cached copy) instead of a
full re-clone of the entire history on every refresh.
Net result: marketplace refreshes use minimal, bounded disk space that does
not grow over time.
### Additional information
_No response_
5 Comments
I put together a narrow patch for this on a fork branch:
Nicolas0315:codex/marketplace-shallow-upgradesc38bdc828 fix(plugins): shallow clone marketplace upgradesWhat it changes:
git clonefor configured git marketplace upgrades now uses--depth 1for the defaultHEADcase and branch/tag-like refs.refs/...paths, so explicit commit/ref checkouts do not lose reachability..git/shallow, one reachable commit) and that a successful upgrade leaves nomarketplace-upgrade-*staging dir behind.Verification:
just fmtjust test -p codex-core-plugins marketplace_upgrade-> 12 passedcargo check -p codex-core-pluginsgit diff --checkrtx4090:just test -p codex-core-plugins marketplace_upgrade-> 12 passedcyberagent-mac-m5max: freshorigin/maincheckout + patch,cargo test -p codex-core-plugins marketplace_upgrade-> 12 passedI also tried opening a draft PR against
openai/codex, but GitHub returned:So I’m leaving the branch/compare here for maintainers.
I hit the same incident class and filed a more detailed follow-up here: #30620.
Additional local evidence in that report: repeated
marketplace-upgrade-*staging dirs under.tmp/marketplaces/.staging, each a full clone of the configured Git marketplace, accumulating to ~155G in one affected environment.I also pushed a narrow cleanup fix branch: riverpilot:fix/marketplace-staging-prune.
That branch addresses the stale-staging cleanup side of this issue:
.tmp/marketplaces/.staging/marketplace-upgrade-*dirs on the configured Git marketplace upgrade pathmarketplace-upgrade-prefixNicolas’s branch, Nicolas0315:codex/marketplace-shallow-upgrades, addresses the other side: reducing future clone size by using
--depth 1for safe HEAD/branch/tag-like marketplace clones.I think these are complementary rather than equivalent:
One nuance: if a successful promotion is directly observed leaving its
marketplace-upgrade-*dir behind, that would be an immediate cleanup bug. From the current code path, normal successful promotion should move/drop the temp dir; the durable leak I reproduced is abandoned staging dirs that are not later pruned.I reproduced this incident class and found a second trigger beyond orphaned
TempDirs: multiple Codex processes can read the same stale marketplace revision, then each perform the same upgrade even after another process has already activated it. In the affected Windows environment, staging grew from 45 to 83 directories (about 9.8 GiB total), with a new full marketplace clone appearing roughly every five minutes.I prepared a bounded fix on a fork branch:
Clay996:fix/marketplace-upgrade-bounds64bdf393f45f06565cf96c632d18d98959bc6104The patch combines the two existing partial directions in this issue with the missing correctness and resource bounds:
Verification on the branch:
codex-core-pluginscrate: 408/408 passed, with one pre-existing environment-only WSL Git compatibility test skipped;just fix -p codex-core-plugins: clean;Per the repository's invitation-only contribution policy, I have not opened an unsolicited PR. If maintainers want this broader fix, please invite a PR and I will submit the branch with the issue linked.
I encountered the same issue on Windows with Codex CLI 0.147.0, and wanted to add another data point because the behavior I observed may help distinguish successful-upgrade cleanup from abandoned staging cleanup.
Environment
codex-cli 0.147.0CODEX_HOME: not set at process, user, or machine scope~\.codexWhat I observed
Under:
I found well over 100 directories with names of the form:
The oldest one I observed dated back to early June, with many more accumulating through July and August.
There were periods where new directories appeared only minutes apart, and in some cases multiple directories had timestamps only seconds apart.
The accumulated staging directory was approximately:
None of the active marketplace roots reported by:
pointed into any of these
marketplace-upgrade-*directories.Cleanup / validation test
To avoid deleting potentially active state, I:
.stagingto a temporary backup.The upgrade completed successfully:
During this fresh upgrade, Codex recreated:
and updated the marketplace successfully.
Crucially, after the successful upgrade completed, the newly created
.stagingdirectory contained no leftovermarketplace-upgrade-*directories.I then removed the old staging backup and recovered approximately 5.14 GB.
Additional stale backup
I also found an older sibling directory with a name of the form:
It was roughly a month old, was not referenced by any active marketplace root, and remained present across successful marketplace operations. I removed it separately after verifying it was not in use.
What this seems to suggest
At least in my case, a normal, manually triggered successful marketplace upgrade cleaned up its current staging directory correctly.
The disk growth therefore appears more consistent with staging directories being abandoned by earlier upgrade attempts/processes and never being reclaimed afterward, rather than every successful upgrade deterministically leaking its temporary directory.
That seems consistent with the distinction mentioned above between:
marketplace-upgrade-*directories from interrupted, failed, concurrent, or otherwise incomplete upgrade attempts not being pruned later.The timestamp pattern was notable because there were clusters of repeated staging directories created at short intervals over extended periods, rather than just one or two isolated leftovers.
Expected behavior
Even when an upgrade is interrupted, fails, or its creating process exits unexpectedly, stale directories such as:
should eventually be reclaimed safely—for example during a subsequent startup or marketplace upgrade—so disk usage remains bounded.
It would also be useful if stale
marketplace-backup-*directories were subject to similarly conservative cleanup when they are no longer referenced.Happy to provide additional diagnostics if there is a specific command or metadata that would help, provided it can be shared with user paths / marketplace details redacted.
I can confirm this issue on Linux with a public Git-backed marketplace.
Environment
codex-cli 0.147.0https://github.com/Gentleman-Programming/engram.gitObserved disk growth
First occurrence:
marketplace-upgrade-*directories~/.codex/.tmp/marketplaces/.stagingAfter deleting those confirmed orphaned staging directories, the problem recurred within roughly 18 hours:
marketplace-upgrade-*directoriesThe active marketplace root remained valid, and Codex's marketplace metadata advanced its
last_updatedandlast_revisionvalues. None of the active marketplace roots reported bycodex plugin marketplace list --jsonpointed into the staging directories.Cleanup and workaround
I removed only the orphaned
marketplace-upgrade-*directories after verifying the active marketplace root was elsewhere. This reduced~/.codexfrom approximately 57 GB to 958 MB and restored free disk space from 6.4 GB to 62 GB.As a temporary mitigation, I changed this Codex-only marketplace registration from a Git source to a local source containing the same verified revision. The plugin remained installed and enabled, and no new staging clone appeared during an immediate observation window longer than the previous approximately one-minute creation cadence.
This looks consistent with abandoned or concurrent Git marketplace upgrade attempts not being reclaimed, rather than normal plugin/session storage growth.