OR博客
GPG卡死问题
苗锦洲
创建于:2024-03-24 09:27:26
河南省
0
22
606
0
由于意外退出导致无法释放加锁,删除`.lock`文件即可

由于意外退出导致无法释放加锁,删除 .lock 文件即可

Issue #1021 · linuxboot/heads

Hi,

This indicates the presence of a** lock file within ~/.gnupg or its subfolders, likely located within the \~/.gnupg/public-keys.d directory, which shouldn't be there. It needs to be removed. For example: \~/.gnupg/public-keys.d/pubring.db.lock. If you run cat on the lock file, you'll find a PID inside the error message removing stale lockfile (created by 17297) or in my case **gpg: Note: database\_open 134217901 waiting for lock (held by 7) ....

Here are some other approaches to prevent this error:

  • Docker:
    When creating your Docker image, include the** **public-keys.d folder like this:
    RUN mkdir -p \~/.gnupg/public-keys.d before importing keys.
  • On a local machine:
    If the folder** **~/.gnupg/public-keys.d doesn't exist, create it before importing keys.
568718040f3d:/# ls -al ~/.gnupg/public-keys.d/ total 84 drwxr-x--- 2 root root 4096 Mar 16 02:34 . -rw-r--r-- 2 root root 27 Mar 16 02:34 .#lk0x00007ff8c7261aa0.buildkitsandbox.7 drwx------ 4 root root 4096 Mar 16 02:34 .. -rw-r--r-- 1 root root 65536 Mar 16 02:34 pubring.db -rw-r--r-- 2 root root 27 Mar 16 02:34 pubring.db.lock 568718040f3d:/# cat ~/.gnupg/public-keys.d/pubring.db.lock 7 buildkitsandbox 568718040f3d:/# gpg --list-keys gpg: Note: database_open 134217901 waiting for lock (held by 7) ... gpg: Note: database_open 134217901 waiting for lock (held by 7) ... gpg: Note: database_open 134217901 waiting for lock (held by 7) ... gpg: Note: database_open 134217901 waiting for lock (held by 7) ... gpg: Note: database_open 134217901 waiting for lock (held by 7) ... gpg: keydb_search_first failed: Operation timed out 568718040f3d:/# rm -f ~/.gnupg/public-keys.d/pubring.db.lock 568718040f3d:/# gpg --list-keys [keyboxd] --------- pub rsa**** 2024-03-15 [SC] B7244*******5341455F5D5*******1F96D uid [ unknown] GitLab ***** (032024) <c*******d@gitlab.com> sub rsa**** 2024-03-15 [E] 568718040f3d:/#

Hope this helps!

评论