codex - 💡(How to fix) Fix Codex Desktop on Windows can leave git diff --numstat readers causing user-mapped section write failures during edits

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

In my case this was caused by Codex Desktop background Git diff processes, not by my application code.

Fix Action

Fix / Workaround

  • Background git diff --numstat scans should be cancelled, sequenced, or avoided before applying patches / rewriting files.
  • Codex should avoid holding long-lived mapped reads over files that the agent may rewrite.
  • The Environment / Changes counter should not repeatedly compute a stale huge branch/base diff when the actual working diff is small.
  • Codex should expose which base/ref the Environment / Changes counter is using, so stale-base problems are diagnosable.

Suggested mitigation:

Codex Desktop should cancel or sequence background git diff --numstat scans before applying patches on Windows, especially when using --numstat -z --find-renames.

RAW_BUFFERClick to expand / collapse

What version of the Codex App are you using (From “About Codex” dialog)?

26.519

What subscription do you have?

plus

What platform is your computer?

windows 10

What issue are you seeing?

On Windows, Codex Desktop intermittently fails to rewrite files in a Git worktree with:

The requested operation cannot be performed on a file with a user-mapped section open.

In my case this was caused by Codex Desktop background Git diff processes, not by my application code.

Codex was spawning long-running commands like:

git diff --no-ext-diff --no-textconv --color=never ... --find-renames --numstat -z

Observed process chain:

Codex.exe -> Python313\Scripts\git.exe -> C:\Program Files\Git\cmd\git.exe -> mingw64\bin\git.exe

While these Codex-spawned git diff --numstat --find-renames processes were alive, normal source rewrites failed. PowerToys File Locksmith showed no normal file holder, and exclusive-open diagnostics could report exclusive_open=ok.

Killing only those Codex-spawned git diff processes made the same file rewrite succeed immediately.

The issue was amplified because Codex Desktop's Environment / Changes counter was showing about 1.5 million changed lines due to a stale base/ref, while the actual working diff shown elsewhere was small.

What steps can reproduce the bug?

  1. Open a Git worktree in Codex Desktop on Windows.

  2. Let Codex Desktop compute the Environment / Changes counter.

  3. Get into a state where the Environment counter is using a stale or unexpectedly large base/ref. In my case it showed about 1.5 million changed lines, even though the actual working diff was small.

  4. Observe Codex-spawned background Git processes like:

    git diff --no-ext-diff --no-textconv --color=never ... --find-renames --numstat -z

  5. While those git diff --numstat --find-renames processes are still running, ask the agent to edit or rewrite source files in the worktree.

  6. The write can fail with:

    The requested operation cannot be performed on a file with a user-mapped section open.

  7. Kill only the Codex-spawned git diff --numstat --find-renames processes.

  8. Retry the same file edit.

  9. The rewrite succeeds immediately.

What is the expected behavior?

Codex Desktop should not allow background Git diff readers to block agent file edits on Windows.

Expected behavior:

  • Background git diff --numstat scans should be cancelled, sequenced, or avoided before applying patches / rewriting files.
  • Codex should avoid holding long-lived mapped reads over files that the agent may rewrite.
  • The Environment / Changes counter should not repeatedly compute a stale huge branch/base diff when the actual working diff is small.
  • Codex should expose which base/ref the Environment / Changes counter is using, so stale-base problems are diagnosable.

Additional information

This reproduced in Codex Desktop on Windows.

The failing writes included source files such as:

src-tauri/src/lib.rs src-tauri/src/game_studio/kanban_adapter.rs

Important observations:

  • This was not caused by my application code.
  • This was not a typical file lock visible in PowerToys File Locksmith.
  • File Locksmith showed no normal process holding the file.
  • An exclusive-open probe could still report exclusive_open=ok.
  • The failure reproduced specifically while Codex background git diff --numstat --find-renames processes were running.
  • Killing those diff processes cleared the immediate write failure.
  • Fixing the stale Git base/ref so the Environment / Changes counter collapsed also made the issue stop happening during normal work.

The Environment / Changes counter showed about 1.5 million changed lines, while the actual working diff was small. That caused repeated heavy background diff scans and made the Windows mapped-section write failure much more likely.

Suggested mitigation:

Codex Desktop should cancel or sequence background git diff --numstat scans before applying patches on Windows, especially when using --numstat -z --find-renames.

It would also help if Codex showed the base/ref used by the Environment / Changes counter.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Codex Desktop on Windows can leave git diff --numstat readers causing user-mapped section write failures during edits