Search code examples
windowsgitgit-bashgnupggpg-agent

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.

However, when I setup the GPG (e.g adding Path etc), I have encountered the following error:

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:

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.

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)

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 git: C:\Program Files\Git\cmd\git.exe

Any help would be appreciated. Thanks


Solution

  • I managed to figure it out.

    This is because the gpg in git for windows uses MINGW64 for the environment. And because I manually set the GNUPGHOME environment variable to a Windows path: C:/users/me/.gnupg, it will not work.

    (I never use the included MINGW64 git bash, I only use cmd and add those exe, like git, gpg into PATH)

    So, if you have manually set the GNUPGHOME env variable, you need to change to a MINGW64 path.

    So in my case, C:/users/me/.gnupg -> /c/users/me/.gnupg

    I am not sure about --homedir though.