Skip to content

Codex VSCode extension corrupts git repositories with fatal: unable to read sha and fatal: Unable to create '.../.git/worktrees/foo/index.lock': File exists. #21823

@eregon

Description

@eregon

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:

  1. Use a git worktree (I'm using https://github.com/truffleruby/truffleruby a reasonable-size but not small git repository)
  2. Configure:
    git config --global core.editor 'code --wait'
  3. Ensure VS Code is not already running
  4. 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.
  5. 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 HEAD seems to fix the git repository, or rm .../.git/worktrees/.../index.lock
  • code --wait --disable-extensions --reuse-window fixes 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingextensionIssues related to the VS Code extension

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions