gpg:找不到密钥块资源pubring.kbx,因为回购路径以gnupg主页为前缀 [英] gpg: keyblock resource pubring.kbx not found because the repo path is prefixed to the gnupg home

查看:760
本文介绍了gpg:找不到密钥块资源pubring.kbx,因为回购路径以gnupg主页为前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经用gpg对提交进行签名,这一切都很好,但是我突然收到了以下消息:

I used to have my commits signed by gpg which worked all fine, but I suddenly got this message instead:

gpg: keyblock resource '/c/Users/username/path/to/project/C:\Users\username\.gnupg/pubring.kbx': No such file or directory
gpg: skipped "my_key": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object

请注意键块资源的路径,它由两条路径组成,并且实际上是无效的.

Note the path of the keyblock resource, it consists of two paths and is indeed not valid.

有关我的设置的信息

我的提交已自动签名,我的设置来自此答案,总之:我像正常情况一样设置了gpg ,然后安装gpg2,并每次使用shell文件将我的密码短语通过管道传输到gpg中.不会,我没有让gpg-agent进行此操作,尽管如果您知道如何做,请回答以下问题:

I had my commits automatically signed, my setup is from this answer, in summary: I set up gpg like normal, then installed gpg2 and pipe my passphrase into gpg every time using a shell file. And no, I didn't get gpg-agent to do this, though if you know how to do it please answer this question: The key whose key-id is in the signature did not sign this commit

我有一个环境变量GNUPGHOME指向C:\Users\username\.gnupg.我尝试将其更改为C:/Users/username/.gnupg,但斜线也刚刚更改了错误.我尝试将其更改为/c/Users/username/.gnupg,但错误消息变为

I have an environment variable GNUPGHOME which points to C:\Users\username\.gnupg. I tried changing it to C:/Users/username/.gnupg but the slashes just changed in the error as well. I tried changing it to /c/Users/username/.gnupg but the error message became

gpg: Fatal: can't create directory '/c/Users/username/path/to/project/C:/Users/username/.gnupg': No such file or directory

我也不知道导致此问题的系统发生了什么变化.

I also don't know what changed on my system that caused this problem.

相关问题

此问题与其他问题非常相似,但未解决: Git提交签名GPG问题 评论是检查gitconfig中的路径,但我认为我在任何gitconfig中都没有指向gnupg目录的路径,无论如何,它都不会以回购的路径作为前缀.我的主~\.gitconfig中有这个:

This question is very similar with a different path but it was not solved: Git commit signing GPG issue The comment is to check a path in a gitconfig, but I don't have a path to the gnupg directory in any gitconfig and it wouldn't be prefixed with the path to the repo anyway, I think. I have this in my main ~\.gitconfig:

[user]
    signingkey = my_key
[commit]
    gpgsign = true
[gpg]
    program = C:\\Users\\username\\gpg-no-tty.sh

也在这里找到了具有相同问题的人: https://jira.atlassian.com/browse /SRCTREEWIN-8527

Also found someone with the same problem here: https://jira.atlassian.com/browse/SRCTREEWIN-8527

不确定这个问题是属于此问题还是属于超级用户,因为我不确定这是程序性还是直接使用(都是?).

From the tag description of gnupg I can't figure out whether this question belongs here or on Super User, because I'm not sure if this is programmatic or direct use (both?).

推荐答案

我遇到了同样的问题.要修复它,我只需要在.gitconfig文件中指定gpg.program变量即可指向我的Gpg4win安装,如下所示:

I had the same issue. To fix it I just had to specify the gpg.program variable in my .gitconfig file to point to my installation of Gpg4win like so:

git config --global gpg.program "%PROGRAMFILES(x86)%\GnuPG\bin\gpg.exe"

git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"

显然,该路径取决于您的gpg二进制文件所在的位置.完成此操作后,它便可以使用我的GNUPGHOME环境变量,并找到用于签名的系统密钥环.但这会使用pinentry提示您输入密钥密码.

Obviously the path depends on where your gpg binary is located. Once I did this, it was able to use my GNUPGHOME environment variable and found my system keyring to use for signing. This will use pinentry to prompt you for your secret key password though.

我相信会出现此问题,因为Windows的Git随附了默认使用的gpg版本.无论出于何种原因,在执行命令对提交进行签名时,似乎本地存储库路径都在gpg主目录路径的前面.

I believe the issue occurs because Git for Windows ships with a version of gpg, which it uses by default. For whatever reason it seems to prefix the local repo path to the gpg home directory path when it executes the command to sign your commit.

希望这会有所帮助

这篇关于gpg:找不到密钥块资源pubring.kbx,因为回购路径以gnupg主页为前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆