Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
nikeedev opened this issue May 17, 2022 · 38 comments
Closed
1 task done

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

nikeedev opened this issue May 17, 2022 · 38 comments
Labels

Comments

@nikeedev
Copy link

nikeedev commented May 17, 2022

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.36.1.windows.1
cpu: x86_64
built from commit: e2ff68a2d1426758c78d023f863bfa1e03cbc768
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22000.675]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VisualStudioCode
Custom Editor Path:
Default Branch Option: main
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

nope

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Powershell on Windows Terminal

git commit -m " *some sort of message here* "
  • What did you expect to occur after running these commands?

It supposed to run commit the update, but also sign it with GPG, so it will open up a new window where i write my password to accept the commit, and thats all.

  • What actually happened instead?

Instead, it tried to open a window but it closed, and after some waiting i get this output:

gpg: can't connect to the agent: Invalid value passed to IPC
gpg: keydb_search failed: No agent running
gpg: skipped "ED44E0EAA7BBF26B": No agent running
gpg: signing failed: No agent running
error: gpg failed to sign the data
fatal: failed to write commit object

Another strange thing happening, is that running gpg gives out that the command isnt valid or doesnt exist. I tried reinstalling git, but some why, it didn't install gpg together with git. I found out that gpg lies in C:\Program Files\Git\usr\bin folder, but even setting it to environment variables, it wont run....

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

It did happen on all repos.

@nikeedev
Copy link
Author

also the C:\Program Files\gpg folder doesnt exist, it just disappeared...strange

@rimrul
Copy link
Member

rimrul commented May 17, 2022

GPG didn't install together with Git

gpg: can't connect to the agent: Invalid value passed to IPC
gpg: keydb_search failed: No agent running
gpg: skipped "ED44E0EAA7BBF26B": No agent running
gpg: signing failed: No agent running

These error messages seem to come from GPG, so I'd argue it's installed. It does sound like you're not running the GPG agent (or at least not the version gpg expects), though.

This might be related to #2445.

also the C:\Program Files\gpg folder doesnt exist

Why would that exist? It certainly isn't related to Git for Windows.

@rimrul rimrul added the unclear label May 17, 2022
@nikeedev
Copy link
Author

GPG didn't install together with Git

gpg: can't connect to the agent: Invalid value passed to IPC
gpg: keydb_search failed: No agent running
gpg: skipped "ED44E0EAA7BBF26B": No agent running
gpg: signing failed: No agent running

These error messages seem to come from GPG, so I'd argue it's installed. It does sound like you're not running the GPG agent (or at least not the version gpg expects), though.

This might be related to #2445.

Have you seen whats in issue #2445?

There is literally no answer there.

(or at least not the version gpg expects), though.
Wasnt git developers supposed to fix problems with versions? I understand that it could be issue the version, but how can i fix that when i officially installed git, with all functions and programs, but still get the error...like how?

@dscho
Copy link
Member

dscho commented May 17, 2022

There is literally no answer there.

That's exactly why I closed it.

This might be related to #2445.

I don't think so, as "Invalid value passed to IPC" is a distinctly different error than "IPC connect call failed".

Just so we're talking about the same thing, do you see the same gpg version?

$ gpg --version
gpg (GnuPG) 2.2.29-unknown
libgcrypt 1.9.3-unknown
Copyright (C) 2021 Free Software Foundation, Inc.
License GNU GPL-3.0-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

We did have a problem recently where dirmngr --help would abort with a segmentation fault, and that was the underlying problem why the agent could not be started.

If that's not it, and if you really use the same gpg as I do, then you will need to enable debug logging (probably by changing the config accordingly) to diagnose better what is going wrong.

@nikeedev
Copy link
Author

There is literally no answer there.

That's exactly why I closed it.

This might be related to #2445.

I don't think so, as "Invalid value passed to IPC" is a distinctly different error than "IPC connect call failed".

Just so we're talking about the same thing, do you see the same gpg version?

$ gpg --version
gpg (GnuPG) 2.2.29-unknown
libgcrypt 1.9.3-unknown
Copyright (C) 2021 Free Software Foundation, Inc.
License GNU GPL-3.0-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

We did have a problem recently where dirmngr --help would abort with a segmentation fault, and that was the underlying problem why the agent could not be started.

If that's not it, and if you really use the same gpg as I do, then you will need to enable debug logging (probably by changing the config accordingly) to diagnose better what is going wrong.

I literally wrote that in beginning, that my gpg doesnt work! I cant run it. It says that command is invalid or not existing. Writing where gpg gives back not path but error that it doesn't find. How can i run gpg if i dont need to find it @rimrul?

@rimrul
Copy link
Member

rimrul commented May 17, 2022

I don't think so, as "Invalid value passed to IPC" is a distinctly different error than "IPC connect call failed".

Right. My bad. I went looking through the older GPG related issues and saw that one with the IPC error message and thought it was the same error message, but didn't actually compare them closely. Sorry.

@nikeedev
Copy link
Author

Do you know whats the issue that happens to me @dscho?

@rimrul
Copy link
Member

rimrul commented May 17, 2022

I literally wrote that in beginning, that my gpg doesnt work! I cant run it. It says that command is invalid or not existing. Writing where gpg gives back not path but error that it doesn't find. How can i run gpg if i dont need to find it @rimrul?

Could you check the output of git config --get-all gpg.program and if that returns nothing the output of "C:\Program Files\Git\usr\bin\gpg.exe" --version?

@nikeedev
Copy link
Author

nikeedev commented May 17, 2022

git config --get-all gpg.program

returned nothing

output of "C:\Program Files\Git\usr\bin\gpg.exe" --version?

here it is:

gpg (GnuPG) 2.2.29-unknown
libgcrypt 1.9.3-unknown
Copyright (C) 2021 Free Software Foundation, Inc.
License GNU GPL-3.0-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\myftr\.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

@nikeedev
Copy link
Author

sorry if gpg version didnt show, i edit the comment, now it shows.

@dscho
Copy link
Member

dscho commented May 17, 2022

Try running the git commit command after setting $env:GIT_TRACE=1.

@nikeedev
Copy link
Author

nikeedev commented May 18, 2022

Try running the git commit command after setting $env:GIT_TRACE=1.

I get back this:

07:24:17.902053 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
07:24:17.917681 git.c:459               trace: built-in: git commit -m 'Updates'\!''
07:24:17.964562 run-command.c:654       trace: run_command: gpg -bsau ED44E0EAA7BBF26B
gpg: can't connect to the agent: Invalid value passed to IPC
gpg: keydb_search failed: No agent running
gpg: skipped "ED44E0EAA7BBF26B": No agent running
gpg: signing failed: No agent running
error: gpg failed to sign the data
fatal: failed to write commit object

@nikeedev
Copy link
Author

nikeedev commented May 18, 2022

There is a Stack Overflow page where a person used gpg-connect-agent -v

Here is the output for you guys to chew on:

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: Invalid value passed to IPC
gpg-connect-agent: error sending standard options: No agent running

as i understand, gpg-connect-agent doesnt run gpg-agent when it should. Again, i tried reinstalling git, but as you can see, it doesnt really fix the issue...

@nikeedev
Copy link
Author

even running gpg --list-secret-keys --keyid-format=long gives back: gpg: can't connect to the agent: Invalid value passed to IPC

@dscho
Copy link
Member

dscho commented May 18, 2022

I could imagine that there is another gpg-agent.exe running, one that is incompatible with the MSYS variant we're using.

You probably want to increase the debug level of gnupg via the config mechanism I mentioned earlier.

@nikeedev
Copy link
Author

I could imagine that there is another gpg-agent.exe running, one that is incompatible with the MSYS variant we're using.

You probably want to increase the debug level of gnupg via the config mechanism I mentioned earlier.

Can you give what to add, im not common with gpgs config way...

@nikeedev
Copy link
Author

@dscho!!’

@nikeedev
Copy link
Author

Also about debug level options, I said, I can’t access gpg just by writing gpg, it will just give back error,
about that the command or program is not found, and I had ability to access it by default before, but after updating git, I probably didn’t use it in a while, so I didn’t notice that gpg didn’t work…

@dscho
Copy link
Member

dscho commented May 21, 2022

You probably want to increase the debug level of gnupg via the config mechanism I mentioned earlier.

Can you give what to add, im not common with gpgs config way...

I know as much about that as you do, and I would have to read the manual, too. So why don't you cut me out as go-between and read the manual right away?

@nikeedev
Copy link
Author

You probably want to increase the debug level of gnupg via the config mechanism I mentioned earlier.

Can you give what to add, im not common with gpgs config way...

I know as much about that as you do, and I would have to read the manual, too. So why don't you cut me out as go-between and read the manual right away?

Thats okay, but you still didnt answer me, why wasnt gpg set in my environment variables by default by git installer...?

@nikeedev
Copy link
Author

i was running around in google and found this page: https://lists.gnupg.org/pipermail/gnupg-users/2012-April/044112.html. It says to use gpgconf --list-dirs and see if agent-socket:C%3a\Users\user_name\.gnupg/S.gpg-agent doesn't have permission.

Opening the file in vim really does give message that it doesnt have permission to show it.....how can i give gpg access to agent-socket:C%3a\Users\myftr\.gnupg/S.gpg-agent?

@nikeedev
Copy link
Author

they also mentioned to run gpg-agent --daemon --verbose, which results in this:
gpg-agent[824]: ':' are not allowed in the socket name

Can't use ":"? But how can i access C: drive then? i think it is a bug, cause it never was an issue before....

@nikeedev
Copy link
Author

so the problem is either with accesing the file, or the path where ":" can't be used.

@rimrul
Copy link
Member

rimrul commented May 21, 2022

how can i access C: drive then?

/C/Users/user_name/.gnupg/S.gpg-agent could work.

@nikeedev
Copy link
Author

how can i access C: drive then?

/C/Users/user_name/.gnupg/S.gpg-agent could work.

And may i ask you, how can i do that?

Dont say to me to use Google, cause i did.

@nikeedev
Copy link
Author

@rimrul...?

@dscho
Copy link
Member

dscho commented May 21, 2022

gpg-agent --daemon --verbose, which results in this:
gpg-agent[824]: ':' are not allowed in the socket name

You will want to study carefully the full output to find out where that colon comes from. Git for Windows' copy of gpg is an MSYS one, therefore it will want to see paths in Unix-y form, e.g. HOME=/c/Users/nikeedev. If you find out where that path with that colon comes from, you're probably one step away from solving the problem on your side.

@PhilipOakley
Copy link

@nikeedev The user C: drive to /c/ implicit directory conversion for paths has now been added to the wiki / FAQs pages.

It's one of those things that is mentioned in a few places but is easy to miss. (IIUC Cygwin uses /mnt/c/..)

@nikeedev nikeedev changed the title GPG didn't install together with Git | gpg: can't connect to the agent: Invalid value passed to IPC gpg: can't connect to the agent: Invalid value passed to IPC May 22, 2022
@nikeedev
Copy link
Author

Okay, guys i found the problem and it is some why with enviroment variables!

I'm using windows, so i can easily change those variables...the problem was that the GNUPGHOME variable was set to C:\Users\myftr\.gnupg, and as i had it correct, i changed it to /c/Users/myftr/.gnupg and it worked! it understood the socket path and with --verbose i saw that it used actually this path /c/Users/myftr/.gnupg!

But still, why did git installer set the variable to C:\Users\myftr\.gnupg...but it maybe happened when i on Friday (i had the issue since Tuesday this week) that i installed gpg4win, and it maybe did some changes that maybe affected it...but how? I had the issue before i installed gpg4win...are you sure you didn't do anything wrong stuff in the code of the installer, where it changes variables in your latest update....?

@dscho
Copy link
Member

dscho commented May 22, 2022

The Git for Windows installer does not set that environment variable.

@rimrul
Copy link
Member

rimrul commented May 23, 2022

Could we patch gpg to recognize that that variable is always supposed to contain a path and apply Msys2 windows to posix path conversion to it on startup?

@dscho
Copy link
Member

dscho commented May 23, 2022

Could we patch gpg to recognize that that variable is always supposed to contain a path and apply Msys2 windows to posix path conversion to it on startup?

You mean like what we did for SHELL here? I could see myself merging a PR to that extent.

@dscho
Copy link
Member

dscho commented May 23, 2022

You mean like what we did for SHELL here? I could see myself merging a PR to that extent.

OTOH I suspect that this might interfere with non-MSYS installations of GNU Privacy Guard, which exists.

@rimrul
Copy link
Member

rimrul commented May 24, 2022

You mean like what we did for SHELL here? I could see myself merging a PR to that extent.

Similar to that, but I thought we might be able to call the conversio directly from GPG.

OTOH I suspect that this might interfere with non-MSYS installations of GNU Privacy Guard, which exists.

If we do the conversion in Msys2 we'd indeed have to convert it back when calling native executables, like we do with PATH.

@rimrul
Copy link
Member

rimrul commented May 24, 2022

Looking at the linked patch, it seems like it converts the variable in both directions, so I think the same would work for GPGHOME.

@dscho
Copy link
Member

dscho commented May 24, 2022

Looking at the linked patch, it seems like it converts the variable in both directions, so I think the same would work for GPGHOME.

Could you try that? The GitHub workflow of git-for-windows/msys2-runtime should produce a testable artifact.

@rimrul
Copy link
Member

rimrul commented May 24, 2022

Yes, but I probably wont get to it today.

@nikeedev
Copy link
Author

@dscho, @rimrul, you guys can fix this without me. Thanks at least for helping me under the way to fix the issue. A weird one...
But thanks!

@nikeedev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants