WSL: Ubuntu 18.04 gpg dirmngr IPC connect call failed

  • Your Windows build number: 10.0.17134.81

  • What you’re doing and what’s happening:

Building MonoDevelop for Windows looks like a real hassle and there are no binaries available.

I decided to give MonoDevelop for Ubuntu binaries a try on WSL.

I installed a clean Ubuntu 18.04 from the Microsoft Store.

To get it all caught up I executed:

sudo apt-mark hold ebtables # for the current upgrade bug
sudo apt-get update
sudo apt-get upgrade -y

and then I picked up with the MonoDevelop IDE instructions:

sudo apt install apt-transport-https dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

Then I run into an issue.

I receive the following error message:

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
[sudo] password for hayden:
Executing: /tmp/apt-key-gpghome.BG01sRSmD5/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.BG01sRSmD5/S.dirmngr' failed: IPC connect call failed
gpg: keyserver receive failed: No dirmngr
  • What’s wrong / what should be happening instead:

gpg isn’t able to call dirmngr

What I have attempted:

  1. Running dirmngr in another bash instance
  2. Making sure gpg-agent is running in the background
  3. This. https://stackoverflow.com/questions/49496667/gpg-key-generation-canceled and https://stackoverflow.com/questions/46673717/gpg-cant-connect-to-the-agent-ipc-connect-call-failed

Note: I have also tried building MonoDevelop from source on Ubuntu in WSL, but ran into this issue.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 23
  • Comments: 64 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Can try this:

  1. use sudo apt update then will get something like The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5523BAEEB01FA116
  2. Got the pubkey 5523BAEEB01FA116
  3. Use curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x5523BAEEB01FA116" | sudo apt-key add Replace 0x5523BAEEB01FA116 with 0x<your pubkey in 2step>
  4. complete, you can run sudo apt udpate no error

It’s Bugging Since The First Bionics in wsl. But the temporary to pass this problems is using apt-key add instead adv options through wget or curl : curl -sL “http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF” | sudo apt-key add

For those still with the same problem (I had it with MySQL 8 on a fresh Ubuntu 18.04), this solved my problem. In this case, it’s Spotify but it works with any other repository.

$ wget -q "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA87FF9DF48BF1C90" -O- | gpg --dearmor > spotify-A87FF9DF48BF1C90.gpg $ sudo mv spotify-A87FF9DF48BF1C90.gpg /etc/apt/trusted.gpg.d/

1- download the key 2- pass it to gpg to turn the ASCII into binary (unwrapping) 3- move the new file to apt’s keyring.

After that, I was able to do apt update and to install.

I took a look at this today and have determined that this is a timing-related issue that is exposed because of a difference in how Windows and Linux handles connection attempts to localhost sockets. On Linux an attempt to connect to a localhost tcp socket on a port that is not active will return a failure immediately. On Windows there appears to be a 1 second timeout. This causes the following sequence to occur.

  1. gpg spawns dirmngr
  2. dirmngr attempt to connect to localhost port 9050 (this is attempted twice).
  3. gpg attempts to connect to a unix socket that dirmngr creates after the localhost socket connection fails.

This one second timeout in step 2 is enough to cause gpg to think that dirmngr is not responding. There appears to be a retry loop in gpg, but it is not waiting long enough to account for the 1 second connect timeout (the connect is actually attempted twice).

I’ve reached out to some Windows networking experts to determine if there is a way that this timeout can be avoided.

Hello, I arrived to this thread for a similar problem installing MongoDB, but maybe this steps are useful for you too:

(Were ran in Ubuntu 18.04 installed like a subsystem of windows 10)

First download the key manually (This key is for mongodb-org repository)

wget https://www.mongodb.org/static/pgp/server-4.0.asc

Add key manually

sudo apt-key add server-4.0.asc

Remove it

rm server-4.0.asc

Update package list

sudo apt-get update

Install MongoDB-org

sudo apt-get install -y mongodb-org

That’s it, I hope to have helped to anyone.

Cheers!

For future reference, manual solution is this: $ curl -sL “https://www.mongodb.org/static/pgp/server-4.0.asc?_ga=2.264892495.1953852568.1531143056-750073170.1531143056” | sudo apt-key add

@foxliu hey I tried your steps

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

converted to:

curl -sL “http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x9DA31620334BD75D9DCB49F368818C72E52529D4” | sudo apt-key add

did I did this right?? it returned Ok. then I just proceeded to install MongoDB works just fine.

same error while installing mongodb

I hate to look a ‘closed’ gift horse in the mouth, but this one merits some further attention because it will keep coming up until we have a work-around on the books for the dirmngr fail proper. The problem is unrelated to Mono or MonoDevelop, natch. MariaDB (key 0xF1656F24C74CD1D8) fails the same, as will every apt-key howto anyone has ever posted on the Interwebs.

The problem is that dirmngr (sudo apt install dirnmgr) isn’t running (or isn’t autolaunched?) and thus there is nothing on the other end for apt-key via gpg to talk to. After around half an hour of investigation, like @sirredbeard, I wasn’t able to make dirmngr at home on WSL manually. Maybe someone else will have better luck or suggestions.

I can’t even use apt-key add because it also bombs out. So here’s a super-manual way to get this done:

curl https://download.mono-project.com/repo/xamarin.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/mono.gpg

Putting this here in case I’m not the only person for whom this is a mission 😕

image

Both didn’t work though.

This issue still exists in 20.04. The original workaround (calling apt-key add - manually) no longer works. @tsilefy’s workaround above does work. Is there any change of getting this resolved for good?

If you need to install something from Microsoft, say like Azure CLI

wget https://packages.microsoft.com/keys/microsoft.asc

Following the guide by @jefraroce helped me

@benhillis For those of us not on an insider build and have no possibility to go to one (corporate network), is there any way to get this fix?

@buddha314: there is a Q&A on ROS Answers about this (this one).

I took another look this morning and found the bug in gpg. Their retry loop waiting for dirmngr to come up is passing an invalid argument to the nanosleep system call. From the nanosleep man page:

The value of the nanoseconds field must be in the range 0 to 999999999.

The retry loop starts with a relatively small sleep and doubles the duration, eventually capping out at one second. However they pass 1 second as 1000000000 nanoseconds, which returns EINVAL immediately.

This was actually already fixed by this commit (but it appears 18.04 is using an older version): https://github.com/gpg/gnupg/commit/0cfdd3b57d592fb6baa7dafe8fde124e8a6c7798#diff-01af2aa0c9e9ef29097d81dfcf608938

@veloscillator which Windows build? in Ubuntu 20.04 libc6 is broken in WSL1 and shows a very similar error message. You can try #5125 (comment) as workaraound.

This resolved my issue, thank you (I’m on 2004 19041.208).

If you need to install something from Microsoft, say like Azure CLI

wget https://packages.microsoft.com/keys/microsoft.asc

Following the guide by @jefraroce helped me

Where is the guide @ppumkin ? I am stuck on this now - thx!

Use what @jefraroce has written up just aboive my previous comment. In particular

wget https://www.mongodb.org/static/pgp/server-4.0.asc

would be

wget https://packages.microsoft.com/keys/microsoft.asc

and follow the rest of the steps to install the key substituting the file name for the one downloaded above.

Follow the https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

sudo service mongod start (Will not work with WSL)

Step1 : sudo mkdir -p /data/db

Step2 : sudo mongod --dbpath /data/db

This will start the mongod server in WSL without any additional procedures

Step3 : mongo 👍

@xsqian I had the same problem with Azure CLI, so I stole the command from the SQL Server Linux install (https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017) and got it to work:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

Anyone having any the same issue when trying to install Mono for Ubuntu 18.04 (https://www.mono-project.com/download/stable/#download-lin) in WSL?

I’ve tried the suggested work around but I’m not able to find the key (3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF) that is required for Mono on the Ubunutu key server site (http://keyserver.ubuntu.com/) and not surprisingly it’s not worked when using curl.

Edit: Sorry saw that there was a link to this issue here for mono which has a work around of applying this command:

curl https://download.mono-project.com/repo/xamarin.gpg | sudo apt-key add -

I’d like to report that any debian based distro (possibly any distro) utilizing an updated dirmngr before 18.04 was officially released as LTS was recieving this error. The issue was resolved just in time for 18.04 release. So this may be a regression or something Ubuntu did to screw with it.

When I had experienced this error utilizing Debian Buster, I simply reinstalled Debian from the Store after 18.04 was released and the updated package containing the fix was imported when upgrading from Stretch to Buster. As of yesterday evening, I have yet to see this issue re-occur.

The work-around mentioned above failed at the time and did prevent any package (including stock) from successfully upgrading. Even apt update failed.

I would recommend others test a different distro other than Ubuntu 18.04 that uses the same version of dirmngr (or upgrade to it if not part of the base) and see if it still has an issue.

For completeness, I’m running build 17134 with the latest patch.

but sometimes in metapackages with ubuntu-desktop when i was want to install Crystal Language by importing their gpg and it’s works through the adv options

I support re-opening for the wider issue with dirmgr.

I think I was able to import the key by curling it in and piping it to apt-key.

Is this only on Ubuntu and only 18.04? If so, should we file a bug report upstream with Canonical?