-
Notifications
You must be signed in to change notification settings - Fork 720
Description
Sometimes, jj
errors out after 'failing to reset Git HEAD state':
$ jj status
Error: Failed to reset Git HEAD state
Caused by:
1: Could not acquire lock for index file
2: The lock for resource '/my/repo/.git/index' could not be obtained immediately after 1 attempt(s). The lockfile at '/my/repo/.git/index.lock' might need manual deletion.
We see this error pretty frequently, but we do not yet have a good reproducer.
In general, it is not obvious why this issue occurs or what causes it.
Workaround
Like the message says, rm .git/index.lock
seems to work, although we'll also frequently need to run jj workspace update-stale
and resolve a conflicted revision.
Clues
What follows are some clues that may or may not be relevant.
git status
still works
Even if jj
can't get the lock to run jj status
, git status
computes the working changes correctly.
git maintenance
is not running
Unlike #7210 (comment), we do not have git maintenance
enabled or running.
fsmonitor
is watchman
We do have the watchman
fsmonitor
enabled, scoped to the repo to work around #5817:
fsmonitor.watchman.register-snapshot-trigger = true
[[--scope]]
--when.repositories = [
"/my/repo",
]
fsmonitor.backend = "watchman"
lsof
is uninteresting
nvim
seems to be holding a reference to the .git/HEAD
, but not the index. This seems to be present regardless of if the bug is occurring, but it's definitely something to investigate.
$ lsof | head -n1; lsof | rg "/my/repo/.git"
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nvim 67118 wiggles 15r REG 1,19 41 128747037 /my/repo/.git/HEAD
Specifications
- Platform: macOS Tahoe 26.0
- Version: jj 0.33.0
Related
- Frequent issues with .git/packed-refs #6203
- Similar issue, but with
.git/packed-refs
rather than.git/index
.
- Similar issue, but with
- Failed to reset Git HEAD state leading to disappearing file #7210
- Same error message, but caused by
git maintenance
- Same error message, but caused by