The issue begins with me unable to sign my Git commit.
$ git commit --verbose -S -sam "Attempt to sign commit"
gpg: invalid size of lockfile 'C:\Users\username\.gnupg/gnupg_spawn_agent_sentinel.lock'
gpg: cannot read lockfile
gpg: can't connect to the agent: Invalid argument
gpg: keydb_search failed: No agent running
gpg: skipped "KEY_ID_ABC123": No agent running
gpg: signing failed: No agent running
error: gpg failed to sign the data
fatal: failed to write commit object
It seems that I'm unable to sign because the GPG agent is not running, and the agent is not running because of the invalid lockfile size of gnupg_spawn_agent_sentinel.lock
.
Running gpg -K
also gives me a similar error:
$ gpg -K
gpg: invalid size of lockfile 'C:\Users\username\.gnupg/gnupg_spawn_agent_sentinel.lock'
gpg: cannot read lockfile
gpg: can't connect to the agent: Invalid argument
I checked the file size of ~/.gnupg/gnupg_spawn_agent_sentinel.lock
$ ll ~/.gnupg/ | grep gnupg_spawn_agent_sentinel
-rw-r--r-- 1 username 1049089 0 Dec 16 16:53 gnupg_spawn_agent_sentinel.lock
It shows that gnupg_spawn_agent_sentinel.lock
is 0 bytes! Home come? And how can I proceed from here to resolve this error?
Apparently deleting the corrupted .lock
file resolves my issue.
# "delete" by backing up, just in case
mv ~/.gnupg/gnupg_spawn_agent_sentinel.lock ~/.gnupg/gnupg_spawn_agent_sentinel.lock.bak-YYYY-MM-DD
I'd appreciate if anyone can elaborate what the lock file is for, as well as side-effects of this solution, if any.