Codex Desktop on Windows exits after background git add -A runs against home directory

Open 💬 3 comments Opened Jun 9, 2026 by bilbillm
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Summary

Codex Desktop on Windows repeatedly exits without a visible error while working in project-level workspaces under Documents\GitHub. The Windows AppX container is destroyed, and there is no Crashpad/WER crash dump.

The desktop logs show that, even while the active workspace is a normal project folder, background git snapshot/review jobs repeatedly run heavyweight git commands directly with cwd=C:/Users/<user>, including git add -A. If the user's home directory contains a .git folder, Codex attempts to index the whole home directory, including AppData/cache/runtime/node_modules paths. This produces long-path and permission errors and appears correlated with the desktop app disappearing.

This looks related to #19588 and #20933, but in this case the visible symptom is the entire Windows desktop app/container disappearing after some time.

Environment

  • OS: Windows 11
  • Codex Desktop package: OpenAI.Codex_26.602.4764.0_x64__2p2nqsd0c76g0
  • Git: git version 2.51.0.windows.1
  • Active workspaces when this happens: project folders under C:\Users\<user>\Documents\GitHub\...
  • Home directory also has a .git directory: C:\Users\<user>\.git

Observed Behavior

After some time (often tens of minutes to a couple of hours), Codex Desktop disappears without warning. Window and background processes exit together.

Windows AppModel-Runtime/Admin logs show the whole AppX container being destroyed:

2026-06-09 10:59:24 Launch process 7576 for package OpenAI.Codex_26.602.4764.0_x64__2p2nqsd0c76g0
2026-06-09 11:30:07 Destroyed desktop AppX container {1C2C6150-63AC-11F1-A44A-C0353219DD02}
2026-06-09 11:30:13 Launch process 32104 for package OpenAI.Codex_26.602.4764.0_x64__2p2nqsd0c76g0

There are no Codex Crashpad reports and no matching Windows Error Reporting crash dumps.

Relevant Codex Logs

Even after opening/resuming a project-level workspace, the desktop logs repeatedly show background git work using the home directory as the cwd:

warning [git] git.command.complete ... command="'C:\\Program Files\\Git\\cmd\\git.exe' -c core.hooksPath=NUL -c core.fsmonitor= add -A" cwd=C:/Users/<user> durationMs=98272 exitCode=128 failureReason=command_failed requestKind=review-summary source=review_model stderrBytes=11205 subcommand=add success=false

Another repeated command:

warning [git] git.command.complete ... command="'C:\\Program Files\\Git\\cmd\\git.exe' -c core.hooksPath=NUL -c core.fsmonitor= config --get remote.upstream.url" cwd=C:/Users/<user> exitCode=1 requestKind=gh-pr-status source=local_conversation_git_summary

When git add -A runs against the home directory, it tries to index runtime/cache paths and fails:

warning: could not open directory 'AppData/Local/Application Data/': Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
...
error: open(".cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/.pnpm/@oai+artifact-tool@file+.../node_modules/@oai/walnut/wasm/DocumentFormat.OpenXml.Framework.aaveu4049y.wasm"): Filename too long
error: unable to index file '.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/.pnpm/@oai+artifact-tool@file+.../node_modules/@oai/walnut/wasm/DocumentFormat.OpenXml.Framework.aaveu4049y.wasm'
fatal: adding files failed

The logs also contain many repeated unhandled rejections:

error [electron-message-handler] [desktop-notifications][unhandled-rejection] Error: CancelledError

Workarounds Tried

Setting:

GIT_CEILING_DIRECTORIES=C:\Users\<user>

does not fully prevent this, because some Codex background git jobs use cwd=C:/Users/<user> directly. Git ceiling only prevents discovery from child directories upward; it does not disable a repository when the cwd is the repository root itself.

A stronger local workaround was to edit:

C:\Users\<user>\.git\info\exclude

and add:

/*

After that:

git -C C:\Users\<user> status --porcelain=v1 --untracked-files=normal
git -C C:\Users\<user> add -A --dry-run

both complete without enumerating the entire home directory or hitting long-path errors. Project-level repos under Documents\GitHub\... still work normally.

Expected Behavior

Codex Desktop should not run heavyweight snapshot/review git commands such as git add -A against the user's home directory merely because the home directory has a .git folder or appears in historical/sidebar/thread metadata.

At minimum:

  • Avoid git add -A / branch diff snapshot work for the home directory.
  • Respect a denylist for home/AppData/cache/runtime directories.
  • Do not let failed background git snapshot jobs terminate or destabilize the entire desktop app.
  • Surface a clear warning if a trusted workspace is the user home directory or an unusually large/sensitive directory.

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #26685
  • #26884

Powered by Codex Action

onmokoworks · 2 months ago

Platform: Windows / Codex Desktop

Confirming the same crash pattern, with local logs pointing to the same suspected root cause. After investigating my local logs with Codex's help, I found the following:

Observed in logs:

  • A very large internal git add -- ... with argsCount=1026
  • git add -A running with cwd=C:\Users\<user> (home directory, not the active workspace)
  • Those git add -A calls took 26-32 seconds and exited with exitCode=128
  • worker_rpc_response_error with Permission denied
  • Failed to start turn diff analytics capture

Active workspace at the time:
C:\Users\<user>\Documents\Codex\2026-06-26\new-chat-2

So this looks consistent with the issue description: background Git/diff work appears to be running from the user home directory instead of being limited to the active workspace.

I have a local crash dump available if maintainers need it, but I'm not attaching it publicly because it may contain private paths or session data. I can provide sanitized log excerpts if helpful.

suiyuebaobao · 1 month ago

The background git add -A activity against the home directory here is another Git-backed entry point that this workaround intentionally blocks.

I published a single-file Windows launcher for the original Microsoft Store/MSIX Codex app:

It starts Codex with a process-scoped GIT_DIR=NUL. On my machine, the stable trace changed from 247 new git.exe and 137 new taskkill.exe processes per 10 seconds to 0 and 0 over 15 seconds; WMI Provider Host fell from about 6.6% to 0.9%.

Usage: fully exit Codex from the Windows system tray, then run the script.

This is an unofficial workaround, not an upstream fix. It deliberately disables or limits Review, Changes, branch detection, commit, and other Git-backed Codex features. It does not patch Codex, modify repositories or Git configuration, write system environment variables, require elevation, terminate processes, or remove chat history. Launching Codex normally restores Git integration.