Windows 上 Git GPG 代理的 IPC 错误

IPC Error on GPG Agent with Git on Windows

我想在 Windows 上不安装 Gpg4win 的情况下使用 GPG,因为 Git for Windows 我们很好地包含了 GPG 的二进制文件,所以我想使用它而不是安装额外的应用程序。

但是,当我设置 GPG(例如添加路径等)时,我遇到了以下错误:

C:\Users\me> gpgconf --launch gpg-agent
gpgconf: error running '/usr/bin/gpg-connect-agent': exit status 1
gpgconf: error running '/usr/bin/gpg-connect-agent NOP': General error

gpg-connect-agent:

C:\Users\me> gpg-connect-agent /bye
gpg-connect-agent: no running gpg-agent - starting '/usr/bin/gpg-agent'
gpg-connect-agent: waiting for the agent to come up ... (5s)
gpg-connect-agent: waiting for the agent to come up ... (4s)
gpg-connect-agent: waiting for the agent to come up ... (3s)
gpg-connect-agent: waiting for the agent to come up ... (2s)
gpg-connect-agent: waiting for the agent to come up ... (1s)
gpg-connect-agent: can't connect to the agent: IPC connect call failed
gpg-connect-agent: error sending standard options: No agent running

我需要代理 运行 才能签署 git 提交,所以我不确定发生了什么。

在这个错误发生之前,我使用的是 Gpg4win,它完全没有错误(为了确保它不是版本控制问题,我已经删除了 %userprofile%/.gnupg 中的所有内容)

系统信息:

如有任何帮助,我们将不胜感激。谢谢

我想通了。

这是因为 git 中 windows 的 gpg 使用 MINGW64 作为环境。并且因为我手动将GNUPGHOME环境变量设置为Windows路径:C:/users/me/.gnupg,它不会起作用。

(我从不使用包含的 MINGW64 git bash,我只使用 cmd 并添加那些 exe,例如 git,gpg 到 PATH )

因此,如果您手动设置了 GNUPGHOME env 变量,则需要更改为 MINGW64 路径。

所以就我而言,C:/users/me/.gnupg -> /c/users/me/.gnupg

虽然我不确定 --homedir

我在新的 MacOS (Monterey) 上全新安装 gnupg2 时遇到了同样的问题。安装似乎没有创建 .gnupg 文件夹。

在我的例子中,这是通过 运行:

解决的

gpg -K

这导致创建了缺少文件夹

gpg: directory '/Users/xxx/.gnupg' created 
gpg: keybox '/Users/xxx/.gnupg/pubring.kbx' created
gpg: /Users/xxx/.gnupg/trustdb.gpg: trustdb created

一切顺利。