gpg: can't connect to the agent: IPC connect call failed (WSL Ubuntu 20.04)
13,032
Solution 1
This appears to be a known bug in WSL. You can try adding the key manually using:
curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=YOUR_KEY_HERE" | sudo apt-key add
YOUR_KEY_HERE
is the GPG key the package you need wants to install. An example would be: 0xA6A19B38D3D831EF
Solution 2
Uninstall the gpg that comes installed by default and install gnupg1 package instead
sudo apt remove gpg
sudo apt install gnupg1
Related videos on Youtube
Author by
Dmitriy Lyutov
Updated on September 18, 2022Comments
-
Dmitriy Lyutov over 1 year
after updating WSL Ubuntu i can't do
sudo apt-key add
with an error:gpg: can't connect to the agent: IPC connect call failed
-
Feodor Fitsner about 4 yearsThat bug is for Ubuntu 18.04 WSL, but I never had such issues in 18.04. 20.04 is failing out of the box.
-
Dmitriy Lyutov about 4 yearsThank you! It's also possible to copy a key to folder /etc/apt/trusted.gpg.d/ manually
-
ijustlovemath about 4 years@DmitriyLyutov that's not recommended, as apt does not keep track of manually added keys. Use the package management utilities whenever you can to keep things maintainable!
-
GPHemsley almost 4 yearsThis solution didn't work for me, but you can extract the keyid from this output:
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg -vv --dry-run --import -
-
Param Siddharth almost 4 yearsThat does the job. Thank you!
-
DISMGMT over 3 yearsThanks, that worked for me too.