Codex VSCode extension corrupts git repositories with `fatal: unable to read sha` and `fatal: Unable to create '.../.git/worktrees/foo/index.lock': File exists.`
What version of the IDE extension are you using?
26.506.31004
What subscription do you have?
Plus
Which IDE are you using?
VS Code
What platform is your computer?
Linux 6.19.14-200.fc43.x86_64 x86_64 unknown
What issue are you seeing?
See repro.
What steps can reproduce the bug?
Repro:
- Use a git worktree (I'm using https://github.com/truffleruby/truffleruby a reasonable-size but not small git repository)
- Configure:
git config --global core.editor 'code --wait'
- Ensure VS Code is not already running
- Run:
git commit enter a message in VSCode, quit with with e.g. Ctrl+W. Might happen more often when not taking long to write the commit message, and maybe also happens more with a larger git repository.
- Observe:
fatal: unable to read <sha>
or:
fatal: Unable to create .../.git/worktrees/.../index.lock
Observations:
- Happens only on VS Code cold start, if VS Code is already running it seems fine
git reset --hard HEADseems to fix the git repository, orrm .../.git/worktrees/.../index.lockcode --wait --disable-extensions --reuse-windowfixes it- Bisected to Codex extension, does not happen with the Codex extension disabled, happens more than half the tries with Codex extension enabled.
A workaround is export EDITOR='code --wait --disable-extensions --new-window' to disable all extensions, or disabling or uninstalling the Codex extension.
A possible cause might be that the Codex extension auto-refresh/git operations are racing on the worktree index during editor startup.
What is the expected behavior?
I would expect the Codex extension to never corrupt my git repository.
Also I expect the Codex extension does not do anything until I start using it, e.g. by opening the Codex chat panel and writing in it.
Additional information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗