Marketplace upgrade staging leak: 559 GB / 4,972 orphaned dirs in 41 days; cleanup janitor exists for curated clones but not marketplaces
Summary
Marketplace auto-upgrade leaked 4,972 staging directories totaling 559 GB in ~/.codex/.tmp/marketplaces/.staging/ over 41 days on my machine. That is the largest instance reported so far (previous high: 277 GB in #29994), so I'm adding it as a data point together with a consolidated root-cause read, because the seven existing reports are all still open with no fix PR.
Environment
- codex-cli 0.147.0 (musl standalone), Fedora 43
- ChatGPT Desktop for Linux with automation extensions active (app-server plugin sync)
- Two configured marketplaces (
claude-plugins-official,cctools-codex-plugins), ~115 MB per full clone
What happened
- First leaked dir 2026-07-09, newest 2026-08-19; 4,972 dirs, 559 GB, ~10 GB/day while the desktop app was open.
- Completed leaked dirs are ~112–117 MB (full clones). The newest one was 18 MB, a partial clone — the process was killed mid-
git clone. This matches the 30-secondMARKETPLACE_UPGRADE_GIT_TIMEOUTtrigger described in #38770: a ~115 MB marketplace on a residential connection can't finish in 30 s, so the upgrade dies every attempt, the revision metadata never updates, and the next sync retries — one orphaned clone per attempt, forever.
Root cause (from reading current main)
codex-rs/core-plugins/src/marketplace_upgrade.rsstages each upgrade intotempfile::Builder::new().prefix("marketplace-upgrade-").tempdir_in(install_root.join(".staging")).TempDircleanup only runs in its destructor. When the upgrade process is killed (clone timeout, OOM, SIGKILL, app-server teardown), the destructor never runs and the directory stays.- Nothing ever sweeps
.staging: the only code in the repo touching that path is the code that creates entries (marketplace_upgrade.rs,marketplace_add/install.rs). There is no startup janitor for it.
The kicker is that the janitor pattern already exists in this codebase for the sibling leak: curated plugin startup sync has remove_stale_curated_repo_temp_dirs(...) (see #16004). It was never applied to marketplace staging.
Prior reports, all open
#21005 (2026-05-04, 187 GB) · #29994 (277 GB) · #30620 · #30794 · #32058 (also covers marketplace-backup-*) · #38770 (timeout trigger) · #39332 (filed 2026-08-19). Amplifiers: #36093 (concurrent processes), #34128 (annotated-tag upgrade loop), #24815 (the 30 s timeout itself).
Suggested fix
- On startup (or before each upgrade attempt), remove
.staging/marketplace-upgrade-*entries older than some small age, mirroringremove_stale_curated_repo_temp_dirs. - Optionally make the clone timeout proportional to marketplace size or resumable; shallow clones (#29994 suggestion) shrink the per-leak cost but don't stop the leak.
Happy to open a PR porting the existing janitor pattern to installed_marketplaces.rs if maintainers confirm that's the preferred shape.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #39332
- #38770
Powered by Codex Action
Adding a Windows data point, since every detailed report on this leak so far (including this one, #39332, and #29994) is from Linux/macOS. The behaviour reproduces identically on Windows 11, and the leak rate matches yours almost exactly.
Environment
- Windows 11 Pro 10.0.26200
codex-cli 0.145.0-alpha.4- Codex desktop app (MS Store
OpenAI.Codex) also installed and running during the day - 2 configured marketplaces (
sendbird,text-to-cad) +openai-bundled; ~160 MB per fulltext-to-cadclone
What I found
%USERPROFILE%\.codex\.tmp\marketplaces\.staging\ had accumulated 101 orphaned directories / 13.78 GB / 96,174 files. The .git directories alone accounted for 10.96 GB across 97 clones.
Directory naming was 101/101 marketplace-upgrade-<6 chars> — zero unexpected entries.
Remote census (all 101 enumerated, not sampled)
| count | remote.origin.url |
|---|---|
| 90 | https://github.com/earthtojake/text-to-cad.git |
| 5 | https://github.com/sendbird/codex-marketplace.git |
| 6 | no remote configured |
Those 6 clones with no remote at all are, I think, the most useful part of this report: they are clones killed before git remote add completed. That is direct corroboration of the timeout-kill chain you and #38770 describe — the process dies mid-clone, TempDir's destructor never runs, revision metadata never updates, next sync retries, one orphan per attempt.
git status --porcelain on a 5-directory spot check: all clean, no user data.
Leak rate
I sampled timestamps on 20 of the 101 directories. All 20 fell on a single day, spread across the working day:
07:15 07:37 07:53 08:03 08:41 08:57 09:01 09:15 09:59 10:37
10:39 10:57 12:11 12:25 13:37 13:53 14:16 15:25 18:20 20:13
That is roughly one orphan every 20–40 minutes, ≈ 13.8 GB/day at ~160 MB per clone — versus the 13.6 GB/day implied by your 559 GB / 41 days. Two very different platforms, two different marketplace sets, essentially the same rate. That's consistent with the leak being driven by the sync retry interval rather than by anything environment-specific.
Impact here: a 200 GB system drive went to 8.5 GB free.
Cleanup is safe (data point for anyone landing here from a search)
I deleted .staging/ outright and verified afterwards:
~/.codex/sessions/— 873 files / 9.78 GB, byte-identical to the pre-deletion baseline; oldest (Feb 2026) and newest sessions still parsecodex --version,codex plugin marketplace list,codex plugin list— all normal, 3 marketplaces detected, all pluginsinstalled, enabled- live
marketplaces/sendbirdandmarketplaces/text-to-cadclones intact with valid HEADs logs_2.sqlitewas regenerated automatically
Manual workaround on Windows until a janitor lands:
rd /s /q "%USERPROFILE%\.codex\.tmp\marketplaces\.staging"
Note on the duplicate pile
This is now at least the 9th open report of the same defect (#21005, #29994, #30620, #30794, #32058, #38770, #39332, #39421, plus amplifiers #36093 / #34128 / #24815), the earliest from 2026-05-05. I deliberately commented here instead of opening a tenth. +1 to your offer to port remove_stale_curated_repo_temp_dirs to the marketplace staging path — that seems like the smallest change that stops the bleeding, independent of whatever happens to the 30 s clone timeout.
Fresh datapoint confirming this is still unfixed in 0.147.0 (macOS, Apple Silicon)
Accumulation: 375 orphaned marketplace-upgrade-* dirs under ~/.codex/.tmp/marketplaces/.staging/ (~14 GB total, incl. 45 completely empty = aborted attempts) accumulated between Aug 21–25 while CodexBar ran recurring background codex exec sessions. ~41k files written in the last 24h alone.
Root cause analysis (codex-rs/core-plugins, 0.147.0):
marketplace_upgrade.rs:251-268creates staging clones viaTempDir::tempdir_in(...)with prefixmarketplace-upgrade-; cleanup relies solely onTempDir::Drop, which never runs on SIGKILL or whenMARKETPLACE_UPGRADE_GIT_TIMEOUT(30 s,marketplace_upgrade/git.rs) aborts the operation.- There is no sweeper for marketplace temp dirs — contrast curated clones, which do have one (
startup_sync.rs:400 remove_stale_curated_repo_temp_dirs) — so every orphan persists forever. manager.rs:362/2557gates upgrades behind a process-localin_flight: bool; concurrent processes (menu-bar apps, multiple terminals) each stage their own full clone. This matches the app-server trigger reported here and explains why background session runners amplify the leak so dramatically.- Sibling leaks share the same pattern:
activation.rs:76marketplace-backup-*,marketplace_add.rs:148.keep(), and 0.147.0 additionally leaks underplugins/.marketplace-plugin-source-staging/.
Suggested fix (mirroring the existing curated-repo janitor): sweep .staging entries matching marketplace-{upgrade,add,backup}-* older than ~10 minutes while holding an OS-level lock (mtime alone is unsafe mid-flight, cf. #32058), and/or adopt the 24 h age-gated prune approach from #30620.
Happy to provide additional local traces (lsof snapshots, per-dir timestamps) if useful.
7-day follow-up from the Windows reporter above — regrowth measured, plus a natural experiment that supports the timeout hypothesis
I deleted .staging/ entirely on 2026-08-19 (the 101 dirs / 13.78 GB I reported here). Re-measured today, 2026-08-26, same machine, same codex-cli 0.145.0-alpha.4, no config changes.
It regrew, and nothing self-healed
17 new orphans / 2.67 GB between 2026-08-20 09:45 and 2026-08-26 10:17. Confirms there is no startup janitor and no lazy cleanup on the next successful upgrade — deleting the directory is purely symptomatic.
The rate is not constant — it tracks usage, not wall-clock
| window | orphans | size | rate |
|---|---|---|---|
| 2026-08-19 (~13 h) | 101 | 13.78 GB | ~13.8 GB/day |
| 2026-08-20 → 08-26 (6.0 d) | 17 | 2.67 GB | ~0.44 GB/day |
A 31× swing on an unchanged install. The first window was a heavy Codex day; the second was light. That's inconsistent with a fixed-interval poller and consistent with one orphan per upgrade attempt, i.e. the leak scales with how often the app triggers a sync.
The useful bit: only the large marketplace leaks
Remote census of all 17 (not sampled):
| count | remote |
|---|---|
| 17 | https://github.com/earthtojake/text-to-cad.git (~170 MB) |
| 0 | https://github.com/sendbird/codex-marketplace.git (~2 MB) |
Both marketplaces are configured and both get upgraded. In my 2026-08-19 census the split was 90 / 5 / 6-no-remote — so sendbird did leak occasionally before. Over these 6 days it produced zero orphans while text-to-cad produced 17.
That is close to a controlled experiment on one machine: same client, same scheduler, same network, two marketplaces differing by ~85× in clone size, and only the large one leaks. It's hard to explain that with anything except a size-dependent failure — i.e. the 30 s MARKETPLACE_UPGRADE_GIT_TIMEOUT from #38770 / #24815.
Per-directory sizes back that up
2026-08-20 09:45 3 MB marketplace-upgrade-Ckdxl0 <-- partial, killed early
2026-08-20 10:23 169 MB marketplace-upgrade-iZOngF
2026-08-20 10:58 169 MB marketplace-upgrade-UuxdWd
2026-08-20 11:01 169 MB marketplace-upgrade-G4VqBy
2026-08-20 11:05 169 MB marketplace-upgrade-THJPZn
2026-08-20 11:07 169 MB marketplace-upgrade-0VkEaP
2026-08-20 11:19 169 MB marketplace-upgrade-x5VcTq
2026-08-20 15:38 169 MB marketplace-upgrade-AomJoq
2026-08-22 12:54 171 MB marketplace-upgrade-WxfIsl
2026-08-22 14:59 171 MB marketplace-upgrade-dybpSl
2026-08-25 00:01 172 MB marketplace-upgrade-MckTwN
2026-08-25 02:22 172 MB marketplace-upgrade-BvNmQm
2026-08-25 04:12 172 MB marketplace-upgrade-C7bOyF
2026-08-25 06:12 172 MB marketplace-upgrade-6oH0SZ
2026-08-25 10:22 172 MB marketplace-upgrade-MFZujp
2026-08-25 15:43 172 MB marketplace-upgrade-wKBUF5
2026-08-26 10:17 173 MB marketplace-upgrade-3pmqDo
Three things worth noting:
- Most orphans are complete clones (169–173 MB), not partials. So the clone frequently finishes and the directory is still abandoned. The timeout explains the partials, but a completed-then-orphaned clone points at the
TempDirdestructor also being skipped on the success path (or the process being torn down after clone but before promote). Worth checking both paths, not just the timeout one. - Bursts, not a steady drip — 5 orphans inside 56 minutes on 08-20 (10:23→11:19), then 2 days of nothing. Retry storms while the app is open.
- Sizes creep 169 → 173 MB across the week, tracking upstream repo growth — so the per-leak cost grows over time on its own.
Also of note: 4 of the 17 landed between 00:01 and 06:12 on 08-25, when I was not using the machine interactively. So the sync fires unattended.
Restating the ask
Still no fix on any of the ten open reports. Porting remove_stale_curated_repo_temp_dirs to the marketplace staging path would cap the damage regardless of which of the two failure paths above is responsible. Happy to test a build on Windows if that helps.
Windows workaround, unchanged:
rd /s /q "%USERPROFILE%\.codex\.tmp\marketplaces\.staging"
Verified again today that this is safe: ~/.codex/sessions is untouched, and codex plugin marketplace list / codex plugin list come back clean afterwards.
Fresh datapoint: still reproducible on Codex CLI 0.154.0 / Linux arm64
This is still unfixed in the current latest CLI release and in the Codex Desktop build installed alongside it.
Environment
- Omarchy / Arch Linux, arm64
- standalone Codex CLI
0.154.0 - Codex Desktop
26.901.51231, embedded CLI0.153.4 - one configured Git marketplace:
https://github.com/Gentleman-Programming/engram.git, trackingmain - multiple short-lived and concurrent Codex sessions
Observed impact
- After deleting roughly 50 GB of these clones the previous day, another 31
marketplace-upgrade-*directories accumulated in less than a day. - The 31 directories consumed 1,412.6 MiB; each completed clone was about 46 MiB.
- The directories tracked successive Engram revisions and their timestamps followed Codex usage/session churn.
- The installed marketplace was valid and separate; deleting only
.staging/marketplace-upgrade-*preserved it.
Current source behavior
rust-v0.154.0 and current main have identical marketplace_upgrade.rs content. Startup still spawns plugins-marketplace-auto-upgrade, staging uses TempDir, Git clones have a hard-coded 30-second timeout, and there is no stale marketplace staging janitor. The in-flight guard is process-local, so concurrent/short-lived Codex processes remain an amplifier.
Workaround applied locally
- Pin the marketplace
refto a full 40-character commit SHA. Both CLI 0.154.0 and Desktop's 0.153.4 recognize this and stop startup remote checks/clones once install metadata matches. - Run an hourly user timer that removes only exact
marketplace-upgrade-*directories older than 15 minutes.
After pinning, launching both CLI versions produced zero new staging directories.
A built-in age-gated janitor plus cross-process locking and shallow/incremental fetches would prevent this unbounded disk growth without requiring local cleanup automation.
A fifth leaking prefix nobody has reported yet: git-* in .tmp/ root
The analysis here and in the comments covers marketplace-upgrade-, marketplace-backup-, and plugins-clone-. There is a fourth creation site with the same TempDir-only lifetime, and it is not under .staging/, which is probably why it has gone unnoticed — it sits in $CODEX_HOME/.tmp/ directly, next to plugins/.
codex-rs/core-plugins/src/git_policy.rs, configure_trusted_git_repository:
let staging_root = canonical_home.join(".tmp");
...
let repository = tempfile::Builder::new()
.prefix("git-")
.tempdir_in(staging_root.as_path())?;
It builds a throwaway GIT_DIR (HEAD, empty objects/, empty refs/) to isolate automatic Git commands from repository discovery, and it is called from four places: marketplace_upgrade/git.rs:25 and :62, startup_sync.rs:612, and loader.rs:1893.
macOS, codex-cli, accumulated 2026-04-17 → 2026-09-21:
| Path | Count | Size |
|---|---|---|
.tmp/marketplaces/.staging/marketplace-upgrade-* |
1,085 | 5.0 GB |
.tmp/git-* |
3,901 | 15 MB |
.tmp/marketplaces/marketplace-backup-* |
3 | 35 MB |
Worth stating plainly because it cuts against the framing of this thread: git-* is the most numerous orphan by a wide margin and the least significant by bytes — 4 KB each, since real objects are written into the clone destination, not the GIT_DIR scaffold. It will not show up in anyone's du report, but it is 3,901 inodes and it grows on every automatic Git operation, not only on upgrade attempts. Anyone implementing the sweep should include the prefix; anyone diagnosing by disk size will miss it.
One constraint on the age threshold
The suggested fix here is an age-based sweep, which is right. But the threshold cannot simply be "comfortably above the Git timeout", because not every caller has one:
marketplace_upgrade/git.rs— every step goes throughrun_git_command_with_timeoutwithMARKETPLACE_UPGRADE_GIT_TIMEOUT(30 s).startup_sync.rs—CURATED_PLUGINS_GIT_TIMEOUT(30 s).loader.rs:1903—run_git_outputcallscommand.output()with no timeout at all, andloader.rs:1893gives that clone agit-*GIT_DIR.
A directory's mtime only changes when its direct entries change, and Git writes objects into subdirectories after the initial scaffold, so an in-flight clone does not reliably keep the top-level mtime fresh. A ten-minute window applied to git-* could therefore delete the GIT_DIR out from under a slow but live clone. The bounded prefixes are safe at ten minutes; git-* wants a much wider window (a day is still far below how long these actually survive) or a bound on that call site.
Reference implementation
I have a working patch against main that generalizes remove_stale_curated_repo_temp_dirs into stale_temp_dirs::remove_stale_temp_dirs(parent, prefix, max_age) and calls it from all five creation sites, with the threshold split described above. Tests assert stale removed / fresh kept / unrelated kept, including that an installed marketplace aged past the threshold survives. cargo test -p codex-core-plugins --lib → 463 passed, cargo clippy --all-targets clean.
I understand from docs/CONTRIBUTING.md that external code contributions are not accepted, so this is reference material rather than a PR offer — take, adapt, or ignore as useful: https://github.com/lazybuttrying/codex/tree/fix/marketplace-git-temp-dir-leak
Another way to hit this one, which never stops on its own: a configured git marketplace whose upstream renamed itself fails the name check on every auto-upgrade and leaves a full clone each time. Details in #51609.
I can confirm the issue: Linux, size of ~/.codex/.tmp was about 500GB codex --version codex-cli 0.160.1
macOS reproduction + process attribution for the git-* prefix (0.162.0-alpha.17.2)
Adding a datapoint for the git-* prefix described above, from a newer CLI than the rest of this thread, plus a measurement nobody has done yet: which process actually creates them.
Everything below was measured on the live machine; nothing is inferred from du alone.
Environment
codex-cli 0.162.0-alpha.17.2(/Applications/ChatGPT.app/Contents/Resources/codex-cli/CodexCLI.app/Contents/MacOS/codex)- ChatGPT desktop app
26.1007.30912(build20156), macOS 27.0.1, arm64 - No marketplace-related config;
ghost_snapshotanddesktop.worktree-*keys are absent fromconfig.toml
Accumulation: 1,255 dirs, ~15 MB
| Path | Count | Size |
|---|---|---|
.tmp/git-* |
1,255 | ~15 MB |
First seen 2026-09-08 (birth-time distribution, not mtime), newest just before cleanup on 2026-10-14. Rate is steady, not bursty — birth times show continuous creation:
| Date | Dirs |
|---|---|
| 2026-09-08 | 2 |
| 2026-09-22 | 9 |
| 2026-09-27 | 15 |
| 2026-09-28 | 81 |
| 2026-09-29 | 30 |
| 2026-09-30 | 124 |
| 2026-10-01 | 19 |
| 2026-10-08 | ~168 (peak) |
| 2026-10-14 | 36 |
Two points worth correcting for anyone else measuring this. First, mtime is misleading here: 1,221 of the 1,255 directories share an identical mtime, which is why an earlier pass of mine read them as a single burst. Birth time (stat -f %SB) is what shows the real cadence. Second, du understates this prefix badly — 1,255 empty scaffolds cost ~15 MB of inode/block overhead, which is real but small; the inode count is the actual cost.
Process attribution: created by codex itself, ~3–5 min cadence
I ran a 0.3-second-interval poller on .tmp/ for ~15 minutes and captured 19 creation events. At every event, the creating process tree included:
codex app-server -c features.code_mode_host=true (PID 18641)
codex exec-server --remote https://codex-cloud-environments.chatgpt.com/api (PID 21589)
and a node child of PID 18641 bootstrapping the claude-mem plugin (scripts/mcp-server.cjs). lsof +D reported zero open file handles under any git-* directory at any sample, so these are not in-flight clones — they are abandoned immediately.
That last point is the interesting one relative to the constraint raised in the earlier comment: if a git-* GIT_DIR is genuinely discarded the moment it is scaffolded, the "wide age window so a live clone isn't deleted out from under itself" concern doesn't apply to these at all. All 1,255 contained no files under objects/ or refs/, and every HEAD was just ref: refs/heads/main — the scaffold is written and abandoned before any object is added. A ten-minute sweep would be safe on this data.
I can't say which of the four call sites named above (marketplace_upgrade/git.rs:25,:62, startup_sync.rs:612, loader.rs:1893) is responsible here — my config has no marketplaces configured, so the plugin-sync paths are the more likely candidates but I have not isolated it. loader.rs:1893 (run_git_output, no timeout) would fit the steady ~3–5 minute cadence better than a 30-second-timeout path.
Not caused by local configuration
Full sweep of config.toml found no ghost_snapshot, no ghost_snapshot.ignore_large_untracked_files, no codex-git-root, no desktop.git-worktree-root, no worktree-auto-cleanup-enabled. All defaults. So there is no local setting to turn this off.
Cleanup
Deleted all 1,255 after confirming: zero lsof handles, zero files under objects//refs/ beyond HEAD (1,221 also had a Finder .DS_Store), and no other non-.DS_Store content anywhere in the population. .tmp/ went 167 MB → 152 MB. bundled-marketplaces/, marketplaces/, plugins/ and the lock files were left untouched.
It regrows immediately, and faster than steady
Deleting them is not a fix. With both codex processes still running and no config change:
| Elapsed after deletion | git-* count |
|---|---|
| 0 min | 0 |
| 4 min | 0 |
| 10 min | 0 |
| 11 min | 1 |
| 14 min | 14 |
The first new directory (git-Xs2JEA) is byte-for-byte the same shape as the old population — HEAD = ref: refs/heads/main, empty objects/, empty refs/, zero files beneath either. So the 13-to-14-minute interval was a lull, not the steady rate; under active desktop-app use this prefix accumulates considerably faster than the ~3–5 min I derived from the birth-time histogram, which was itself measured over a window where the app was doing less.
That combination — scaffold written, abandoned, never swept, and regrowth visible within minutes of rm -rf — is the whole bug from a user's side. It doesn't need a fix that preserves a live clone; it needs the scaffold not to outlive the call that made it.
Another data point for this leak, on codex-cli 0.160.1 (macOS, arm64).
$CODEX_HOME/.tmp/marketplaces/.staging/marketplace-upgrade-* accumulated 23 directories (~330 MB) over 19 days. The cause here was that [marketplaces.<name>].last_revision in config.toml stayed at an August revision for 4 of 5 git marketplaces, while each marketplace's .codex-marketplace-install.json and the remote HEAD had moved on. So the auto-upgrade skip condition (last_revision == remote_revision together with matching install metadata) never held, and each periodic upgrade cloned again; any process exit mid-clone left a staging directory behind.
Nothing else on the machine rewrites config.toml, so the post-activation write of last_revision (record_user_marketplace) apparently did not persist. Setting last_revision to the installed revision stopped the re-clones locally. A janitor for .staging/marketplace-upgrade-*, like the one that already exists for curated clones, would bound this; #51609 looks like the same class.
Additional Windows 10 case: os error 5 while replacing the marketplace root, followed by approximately one-minute retry intervals
Cross-posting the Windows evidence from Imbad0202/academic-research-skills-codex#43, as requested by its maintainer. These observations are from October 17, on the pre-fix bundled CLI below; this is not a claim that 0.164.0 still leaks. The bounded retest with the CLI actually used by Desktop is appended below.
Environment at the incident
- Windows 10 Home 22H2, build 19045.6466.
- Codex Desktop using bundled
codex-cli 0.163.0-alpha.10.2; the Desktop app version was not reliably recorded. - Git
2.56.0.windows.2, withcore.longpaths=true. - Marketplace
ars-codex:https://github.com/Imbad0202/academic-research-skills-codex.git, trackingmain. - Installed ARS 3.23.0, marketplace revision
52228e8280dd1770e18ecfc3b1fdf16b13b58104. - An unpromoted staging checkout contained 3.23.1 /
71528d9349bcdacfbe94111f06d9e2d82215a44d.
Observed impact
At one inspection, %USERPROFILE%\.codex\.tmp\marketplaces\.staging held 213 staging directories and .tmp held 378 git-* directories (later 395). Earlier disk scans showed over 10 GB of staging growth, and C: eventually reached 0 bytes free. The git-* entries examined were small templates (21-byte HEAD, empty objects and refs), not the main byte consumer. Deleting old copies and restarting had not prevented recurrence while the Git source remained configured.
Consecutive staging creation times on October 17, UTC+08:00:
01:31:18 01:32:19 01:33:19 01:34:25
01:35:25 01:36:25 01:37:26 01:38:26
Windows-specific error
codex plugin marketplace upgrade ars-codex --json
returned:
Failed to upgrade marketplace `ars-codex`: failed to move previous marketplace root out of the way at %USERPROFILE%\.codex\.tmp/marketplaces\ars-codex: 拒绝访问。 (os error 5)
Error: 1 upgrade failure(s) occurred.
“拒绝访问” means “Access is denied.” The locking process was not identified. A read-only backup was running during this explicit diagnostic attempt, so this error alone does not establish the cause of all previous automatic failures. Separate application warnings also included Git connection resets and an unavailable local proxy; I do not assume those network failures and the directory-replacement failure are one cause.
Workaround and validation
We preserved a verified 3.23.0 snapshot on another drive, replaced only the ars-codex Git marketplace source with that local marketplace through the official CLI, and cleaned verified inactive temporary directories. All other marketplace/plugin settings were preserved. Both temporary-directory counts reached zero, and no new checkout appeared for about ten minutes; plugin list still reported the plugin installed and enabled.
The ARS maintainer has pointed us to the cleanup changes in #55689 and #55690, shipped in 0.164.0. The Windows retest below distinguishes:
- Whether replacement of the old marketplace root still fails.
- Whether a failed or abandoned attempt leaves accumulating staging copies.
- Which Desktop version and actually bundled CLI are being tested, rather than relying on a separately installed CLI.
The working local-marketplace configuration will remain available as the fallback. Paths are redacted; no credentials, complete configuration, or conversation logs are attached.
Windows retest on 2026-10-26
Desktop and runtime actually tested
- Codex Desktop 26.1021.31345, build 21828, release channel
prod. Its configured updater reportsup_to_date. - MSIX package version observed from the running parent process: 26.1021.3705.0.
- The executable used by Desktop's running
app-serverreportscodex-cli 0.164.0-alpha.11.1. This is a prerelease, not the 0.164.0 stable binary; I am not inferring fix inclusion from the numeric version alone. - Windows 10 Home 22H2, build 19045.6466.
Method and scope
The tests used that exact Desktop CLI executable and a separate CODEX_HOME on a secondary local drive. The production local-marketplace configuration was left unchanged. Real ARS source was used for the successful upgrade. Small offline Git fixtures were used to deliberately exercise failure paths, so there was no need to expose the live installation to repeated downloads or change its permissions.
| Case | Observed result |
|---|---|
Unowned marketplace-windows-* fixture |
Reclaimed |
Legacy marketplace-upgrade-* fixture older than 10 minutes |
Reclaimed |
Legacy marketplace-add-* fixture older than 24 hours |
Reclaimed |
| Recent legacy fixture and unrelated sentinel | Preserved on the initial pass; the recent legacy fixture was later reclaimed after it crossed the age threshold |
Real ARS 3.23.0 checkout at 52228e8... upgraded to 3.23.2 / c923a914eaa45fe1435ad3ac6641a8f251167675 |
Upgrade succeeded; no newly orphaned staging or git-* directory |
| Two consecutive upgrades with a readable directory handle denying delete sharing | Both failed at “move previous marketplace root” with os error 32; no new orphan after either failure |
| Same fixture after closing that handle | Upgrade succeeded |
| Add with an intentionally nonexistent Git ref | Checkout failed as expected; no new orphan |
| Upgrade with temporary, non-inheriting delete-denial ACLs on the isolated fixture directory/parent | Failed at “move previous marketplace root” with the exact os error 5; no new orphan |
| Same fixture after restoring the original ACLs | Upgrade succeeded; ACL restoration was verified |
The controlled access-denied output was:
Failed to upgrade marketplace `codex-retest`: failed to move previous marketplace root out of the way at <isolated-test-home>\.tmp/marketplaces\codex-retest: 拒绝访问。 (os error 5)
Error: 1 upgrade failure(s) occurred.
After every completed operation, zero operation-created staging directories and zero git-* directories remained. Intentionally preserved control fixtures are excluded from that statement; they were removed with the isolated test home at the end.
The production config.toml remained byte-identical throughout the retest. Production staging and git-* counts were zero at the start and end, and ARS 3.23.0 remained installed/enabled from the existing local source. The temporary test checkouts were removed afterward.
Conclusion and remaining limitation
The cleanup behavior associated with #55689 and #55690 is observable in this installed Desktop runtime, including cleanup after a controlled Windows os error 5. A permission/sharing violation can still correctly prevent an upgrade; the observed improvement is that the failed checkout does not accumulate.
This does not identify the cause of the original October 17 permission failure, reproduce the Desktop's long-running production Git auto-upgrade loop, or prove a days-long absence of recurrence after re-enabling it. I have therefore retained the working local-marketplace fallback rather than treating these bounded tests as proof that the original production issue is fully resolved.
git-* still leaks on 0.166.0, plus a deterministic lifecycle reproduction
Environment:
- macOS 27.2 (arm64).
- CLI and app-server
0.166.0. - Desktop bundled CLI
0.166.0-alpha.6. - Source at the release tag:
rust-v0.166.0=6ff1e1ca3b30fc8b914720681fcf5fe62e95f856.
What we saw: 5,348 .tmp/git-* directories had built up since mid-October, about 21.8 MB allocated. That is after the 0.164.0 cleanup changes (#55689, #55690). Pinning every marketplace to a full SHA did not stop it. The pin skips the remote-revision lookup, but not the background plugin clones that also take a configure_trusted_git_repository guard (core-plugins/src/loader.rs, run_git_output).
Controlled reproduction. No network or credentials are needed:
- Use an isolated, disposable
CODEX_HOMEwith one local marketplace and one Git-source plugin. - Put a fixture
gitfirst on PATH. Forclone, it recordsGIT_DIR, sleeps 4 s, then writes a minimal plugin manifest into the destination. - Start
codex app-serverover stdio. Callplugin/listwithmarketplaceKinds: ["local"]andforceRefetch: false; this starts the background plugin refresh. - Once the fixture has recorded its
GIT_DIR, close stdin and terminate only that app-server. Let the fixture clone exit normally.
| Case | Clone finished | git-* dir left after server exit |
|---|---|---|
| Server ended during the clone | yes | yes (HEAD, objects, refs) |
| Server ended after the clone's guard dropped | yes | no |
So the leak is the TempDir guard's lifetime. An app-server that exits while a background clone holds the guard never runs its destructor, and nothing reclaims the directory later.
Fix direction: either drain or cancel and join background Git operations at shutdown, or add an owner/liveness-aware janitor for .tmp/git-*. Either way, keep the GIT_DIR isolation, and never sweep in-flight clones by age alone (see the mtime caveat above).
Another data point, codex-cli 0.163.0 on macOS (arm64), several machines.
- Every failed or interrupted marketplace auto-upgrade leaves
~/.codex/.tmp/marketplaces/.staging/marketplace-upgrade-*behind, and nothing in Codex ever removes it. - With
claude-plugins-official(git source) each leftover is a clone of about 38 MB. One machine gained 61 of them in a day, 49 in a single hour while several Codex sessions were busy. - With a larger git marketplace (a repository of about 900 MB whose clone never finished inside the 30-second upgrade timeout), one machine reached 2,324 leftover folders, about 60 GB, and ran out of disk.
Expected: a failed, timed-out or interrupted upgrade removes its own staging folder, or Codex prunes stale .staging/marketplace-upgrade-* folders when it starts.
Workaround we run meanwhile: an hourly job that deletes marketplace-upgrade-* folders older than 60 minutes that no process has open.
macOS: fixed CLI is installed, but a pre-fix binary sharing CODEX_HOME keeps creating marketplace-upgrade-* (27.5 GiB)
Another data point. It explains why some users still see this leak after #55689 and #55690.
Environment
- macOS 27, arm64.
- Three Codex binaries share one
~/.codex:codex-cli 0.169.1from npm. This is the one onPATH. Its strings showmarketplace-upgrade-only asLEGACY_UPGRADE_PREFIX.codex-cli 0.154.0, the Homebrew cask (/opt/homebrew/bin/codex→Caskroom/codex/0.154.0). It was never upgraded after install.~/.codex/packages/app-server-daemon/releases/0.160.0-aarch64-apple-darwin/bin/codex, an old daemon release that is still on disk.
- Strings show that both older binaries contain the
marketplace-upgrade-creator frommarketplace_upgrade.rs(tagrust-v0.154.0, lines 264–272). Neither containsstaging-cleanup.lock.
What we saw
~/.codex/.tmp/marketplaces/.staging/held 28marketplace-upgrade-*directories, 27.5 GiB in total, on a nearly full disk.- Each directory was a full ~1 GB clone of a local git marketplace (
claude-mem-local). - New directories kept appearing several times a day, for example 10:11, 10:37, 10:46, 10:57, 11:05 and 11:34 on one day. That was well after 0.169.1 was installed.
- The installed
claude-mem-localroot was last modified on Oct 21. Its upgrade never succeeded, so every attempt left another clone. .staging.lockand.staging-cleanup.lockexist, which shows the new cleaner has run on this machine. Even so, the backlog did not drain.
What we did not verify
- We did not catch which process started the old binary. When we polled for about 2 minutes, no new directory appeared.
- The daemon's
daemon.stderr.logand pid files were last written on Oct 1–2, so the 0.160.0 daemon release had not run since then. That leaves the 0.154.0 cask as the most likely creator. Our guess at the mechanism: a GUI-launched tool whosePATHhas/opt/homebrew/binbut not the npm prefix resolvescodexto the cask. This is inferred from version strings and timestamps, not observed directly. - We removed the cask and the stale daemon release. We will follow up on whether new
marketplace-upgrade-*directories still appear.
Why this matters after the fix
- A pre-fix binary that shares
CODEX_HOMEwith a fixed one goes on creating legacy directories without limit. Nothing tells the user that an outdated Codex is still in use. A version check on startup ("another Codex older than X wrote to this CODEX_HOME"), or a warning incodex doctor, would surface this. MAX_CLEANUP_DIRECTORIES = 4per pass, incore-plugins/src/marketplace_staging.rs, only runs when an upgrade or add happens. That cannot keep up with a producer that adds about 1 GB several times a day. A byte-based budget, or a larger limit for legacy directories older thanLEGACY_UPGRADE_MAX_AGE, would let the fixed binary recover the disk.
Workaround for affected users: run which -a codex. Upgrade or remove every older copy (brew upgrade --cask codex, and remove old app-server-daemon/releases/*). Then delete ~/.codex/.tmp/marketplaces/.staging/marketplace-upgrade-* directories older than an hour.
Still reproducing on codex-cli 0.172.0 (macOS) — marketplace-backup-* prefix
Data point from a newer release than the ones above.
Environment
- codex-cli
0.172.0 - Codex desktop (
com.openai.codex)26.1120.50957, macOS - One configured git marketplace (~360 MiB checkout)
What I see
- 19
marketplace-backup-<random>directories accumulated in~/.codex/.tmp/marketplaces/between 2026-11-24 and 2026-11-26 (~5.15 GiB, ~0.27 GiB each) alongside the live<marketplace-name>checkout. I removed them by hand. - Within the same day after cleanup, two new
marketplace-backup-*directories appeared 25 minutes apart (314 MiB and 307 MiB), so the rate is roughly one full-size backup per sync while the desktop app is open. - Each backup wraps a checkout with
.gitand plugin manifests, but is incomplete: they are missing 2,143 and 3,155 tracked files respectively — consistent with an interrupted/aborted upgrade whose backup is never cleaned up or restored. .staging/was empty at the time, so on this version the growth is in themarketplace-backup-*prefix rather thanmarketplace-upgrade-*.- Logs show 10
completed remote installed plugin bundle syncevents over the same window; I couldn't tie individual backups to a specific trigger. - No retention/cleanup setting exists in
config.toml(onlymarketplaces.<name>.source/.source_type).
Ask: bounded retention for marketplace-backup-* (e.g. keep the last 1–2, delete on successful activation), and cleanup of backups left by failed activations.