git 如何解决“gnupg_spawn_agent_sentinel.lock”的无效锁文件大小?

disbfnqx  于 2023-01-07  发布在  Git
关注(0)|答案(1)|浏览(121)

问题开始于我无法签署我的Git提交。

$ 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

我似乎无法签名,因为GPG代理没有运行,而代理没有运行是因为gnupg_spawn_agent_sentinel.lock的锁定文件大小无效。
运行gpg -K也会出现类似的错误:

$ 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

我检查了~/.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

它显示gnupg_spawn_agent_sentinel.lock是0字节!回家了吗?我该如何从这里继续解决这个错误呢?

ddrv8njm

ddrv8njm1#

显然删除损坏的.lock文件解决了我的问题。

# "delete" by backing up, just in case
mv ~/.gnupg/gnupg_spawn_agent_sentinel.lock ~/.gnupg/gnupg_spawn_agent_sentinel.lock.bak-YYYY-MM-DD

如果有人能详细说明锁文件的用途,以及此解决方案的副作用(如果有的话),我将不胜感激。

相关问题