Search code examples
git-bashgnupgmaven-gpg-plugin

gpg: can't connect to the agent: Invalid value passed to IPC


Dev environment: Mingw64 that came with Git Bash.

I am trying to sign with maven-gpg-plugin:

 [INFO] --- maven-gpg-plugin:1.6:sign (sign-release-artifacts) @ systemds ---
[INFO] gpg: keybox 'F:\Repo\systemds/pubring.kbx' created
[INFO] gpg: can't connect to the agent: Invalid value passed to IPC
[INFO] gpg: no default secret key: No secret key
[INFO] gpg: signing failed: No secret key

After setting GNUPGHOME, the error message:

[INFO] [INFO] --- maven-gpg-plugin:1.6:sign (sign-release-artifacts) @ systemds ---
[INFO] gpg: can't connect to the agent: Invalid value passed to IPC
[INFO] gpg: can't connect to the agent: Invalid value passed to IPC
[INFO] gpg: keydb_search failed: No agent running
[INFO] gpg: no default secret key: No agent running
[INFO] gpg: signing failed: No agent running


Solution

  • Setting the environmental variable for GNUPGHOME resolves the issue.

    export GNUPGHOME=$HOME/.gnupg
    

    Note: Do not use ~ as ~/.gnupg for representing home.


    Explanation:

    The plugin tried to create the key files in the current directory as we can see by the line

    [INFO] gpg: keybox 'F:\Repo\systemds/pubring.kbx' created
    

    which is resolved after pointing out the GNUPGHOME.