Codex app-server spins on repeated git rev-parse when workspace has invalid empty .git directory
Summary
If a Codex workspace contains a .git directory that exists but is not a valid Git repository, the local Codex app-server appears to enter a tight Git root detection loop. It repeatedly launches:
git -c core.hooksPath=/dev/null -c core.fsmonitor= rev-parse --show-toplevel
On my machine this kept the app-server around one CPU core continuously until the invalid .git directory was fixed.
Environment
- Codex CLI:
codex-cli 0.142.4 - Build path indicated:
0.142.4-x86_64-unknown-linux-musl - OS: Linux x86_64, Ubuntu kernel
7.0.0-27-generic - Surface: Codex desktop/local app-server, process shown as
codex app-server --listen unix://
Likely repro
- Create or open a workspace directory that contains an empty/broken
.gitdirectory:
``bash``
mkdir -p /tmp/codex-broken-git/.git
cd /tmp/codex-broken-git
git rev-parse --show-toplevel
- Confirm Git exits with:
``text``
fatal: not a git repository (or any of the parent directories): .git
- Open that workspace in Codex desktop/app-server.
- Watch the app-server process CPU and child process creation.
Observed behavior
- The app-server stayed hot for several minutes, typically around
90%to160%CPU in interval readings. - A short
stracesample showed1494execveattempts involvinggit ... rev-parse --show-toplevelin roughly 3 seconds. - The app-server repeatedly searched PATH for
git, then launched/usr/bin/git. - The loop persisted after the Codex log database was replaced with a fresh small database, so this did not appear to be caused by log DB corruption.
- Running
git initin the affected workspace, turning the empty.gitdirectory into valid Git metadata, immediately dropped app-server CPU from roughly one core to low single digits.
Expected behavior
Codex should treat an invalid .git directory as either:
- not a Git repository, or
- a recoverable workspace metadata error that is logged/surfaced once,
and then cache/back off the failed root detection. It should not continuously spawn git rev-parse in a tight loop.
Workaround
Either remove the broken .git directory or initialize/fix it:
rm -rf .git
# or
git init
After git init, the app-server CPU returned to normal.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗