简体   繁体   English

Windows 上使用 Git 的 GPG 代理上的 IPC 错误

[英]IPC Error on GPG Agent with Git on Windows

I would like to use GPG without Gpg4win installed on Windows because Git for Windows includes the binary for GPG we well, so I would like to use it instead of installing an extra application.我想在 Windows 上没有安装 Gpg4win 的情况下使用 GPG,因为 Windows 版Git包含我们很好的 GPG 二进制文件,所以我想使用它而不是安装额外的应用程序。

However, when I setup the GPG (eg adding Path etc), I have encountered the following error:但是,当我设置 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

And with gpg-connect-agent :并使用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

I need the agent to be running in order to sign the git commits, so I am not sure what is happening.我需要运行代理才能签署 git 提交,所以我不确定发生了什么。

Before this error happens, I was using Gpg4win, which has no errors at all (to make sure it is not a versioning issue, I have removed everything in %userprofile%/.gnupg )在此错误发生之前,我使用的是 Gpg4win,它完全没有错误(为确保它不是版本问题,我已删除%userprofile%/.gnupg

System Info:系统信息:

  • Windows 10 21H1 19043.1110

  • git version 2.29.2.windows.1

  •  C:\\Users\\me> gpg --version gpg (GnuPG) 2.2.23-unknown libgcrypt 1.8.7 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: C:/Users/me/.gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2
  • where gpg : C:\\Program Files\\Git\\usr\\bin\\gpg.exe where gpg : C:\\Program Files\\Git\\usr\\bin\\gpg.exe

  • where git : C:\\Program Files\\Git\\cmd\\git.exe where git : C:\\Program Files\\Git\\cmd\\git.exe

Any help would be appreciated.任何帮助,将不胜感激。 Thanks谢谢

I managed to figure it out.我设法弄明白了。

This is because the gpg in git for windows uses MINGW64 for the environment.这是因为 git for windows 中的 gpg 使用MINGW64作为环境。 And because I manually set the GNUPGHOME environment variable to a Windows path: C:/users/me/.gnupg , it will not work.并且因为我手动将GNUPGHOME环境变量设置为 Windows 路径: C:/users/me/.gnupg ,它不起作用。

(I never use the included MINGW64 git bash, I only use cmd and add those exe, like git, gpg into PATH ) (我从不使用包含的MINGW64 git bash,我只使用 cmd 并将那些 exe,如 git、gpg 添加到PATH

So, if you have manually set the GNUPGHOME env variable, you need to change to a MINGW64 path.因此,如果您手动设置了GNUPGHOME变量,则需要更改为MINGW64路径。

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

I am not sure about --homedir though.不过,我不确定--homedir

I had the same problem on a fresh install of gnupg2 on a new MacOS (Monterey).我在新的 MacOS(蒙特雷)上全新安装 gnupg2 时遇到了同样的问题。 It seems the installation doesn't create the .gnupg folder.似乎安装不会创建.gnupg文件夹。

In my case this was solved by running:在我的情况下,这是通过运行解决的:

gpg -K

which resulted in the creation of the missing folder这导致创建丢失的文件夹

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

and all was well.一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM