microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.34k stars 814 forks source link

WSL Ubuntu 20.04 - gpg: can't connect to the agent: IPC connect call failed #5125

Closed dawsonc623 closed 4 years ago

dawsonc623 commented 4 years ago

I have a fresh installation of Windows 10, and I am trying to get a development environment with WSL set up. I enabled WSL and installed Ubuntu from the Microsoft Store. Everything went smoothly in that process. Then, I tried to go through the steps to install Yarn here.

When I try to run the first line (curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -), I get the error in the title:

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
gpg: can't connect to the agent: IPC connect call failed

I have looked up this error, and there were a few suggestions related to gpg-agent that I tried, such as manually starting the agent and creating/deleting certain configuration files related to gpg. Everything I tried resulted in the same error above. I am at a loss for what to try next. Has anyone else seen and fixed this issue?

onomatopellan commented 4 years ago

Which Windows build? Ubuntu 20.04 right now is incompatible with WSL1. I just tested in WSL2 and that line runs without problem.

dawsonc623 commented 4 years ago

OS Build 18363.815

I do not think WSL 2 is available to me right now. I am no longer getting preview updates, so I have to wait until the official release.

sirredbeard commented 4 years ago

Can you please run:

$ sudo apt install strace -y

$ strace -o strace.log curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

Then post it to a gist?

maximilia commented 4 years ago

Same issue here

https://gist.github.com/maximilia/a28686972ed9ef2049b2902cdb04e364

sirredbeard commented 4 years ago

Are you on WSL 1 @maximilia?

maximilia commented 4 years ago

@sirredbeard yes, I am

dawsonc623 commented 4 years ago

My trace, if it provides any insight @maximilia's does not:

https://gist.github.com/dawsonc623/06c9300dca0d5504602d6ea3ffe21004

mbjunior79 commented 4 years ago

I got the same error when a tried to run curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

onomatopellan commented 4 years ago

It fails in WSL1 build 19041 and It works in WSL1 build 19613 so I'd say same as #4898.

onomatopellan commented 4 years ago

How to fix this issue until Microsoft releases the fix via Windows Update. Solution by @rafaeldtinoco:

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 -y
sudo apt-mark hold libc6
Kagami commented 4 years ago

@onomatopellan in case if build-essential is installed it should be:

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y --allow-downgrades
sudo apt-mark hold libc6

to avoid g++ removal.

But otherwise it works fine, thanks to you and @rafaeldtinoco.

harryqt commented 4 years ago

That worked, thank you very much.

nardocesar commented 4 years ago

Hey everyone, enabling WSL 2 works for me.

What I did:

jvoss commented 4 years ago

sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y

Will result in:

E: Packages were downgraded and -y was used without --allow-downgrades.

Make sure you add the --allow-downgrades on this step:

sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y --allow-downgrades
bkraul commented 4 years ago

I tried this workaround and it did work but I gotta say it seems like a pretty ugly hack. What are the repercussions of holding back libc6? Is there any hope of "cleanup" to where, after installing the needed key and the packages, everything can be put back the way it was?

alexandrerocco commented 4 years ago

thanks to @rafaeldtinoco and @Kagami for the workaround!

mdragoss commented 4 years ago

I have the same issue with WSL 1 and Ubuntu-20.04, converted it into wsl2 wsl

bkraul commented 4 years ago

For me, WSL2 is a no can do. My dev environment heavily relies on both virtual box and VMware workstation. I know vbox 6 is compatible, but VMware has yet to release their patch...

onomatopellan commented 4 years ago

@bkraul VMWare released a tech preview that works with WSL2. If there are no important bugs this will be next stable release. https://blogs.vmware.com/workstation/2020/01/vmware-workstation-tech-preview-20h1.html

ultramaks commented 4 years ago

Guys, so what do I do if I have 18363 (WSL 1)build only and I need to use gpg? If I use Ubuntu 18.04 instead of 20.04 will it help? Or the only thing is a hack that is described above (by @rafaeldtinoco)

bkraul commented 4 years ago

Pretty much seems to be the only solution for you if going with 20.04. The hack does work, tho. Not sure how intricate your particular WSL instance is, but I would figure if it is not that intricate and you need to use gpg, the hack is worth implementing.

Or yeah, you could try 18.04. I believe 18.04 does not have that issue. At least I do not experience on my 18.04 instance.

bkraul commented 4 years ago

@onomatopellan Thanks, I did check that out. But can't move to it until GA because of critical development environments running on VMware at the moment. I will keep an eye out for both Windows May 20 update and VMWare GA release.

danikhil commented 4 years ago

Temporary Solution: Downgrade libc6 wget https://launchpad.net/~rafaeldtinoco/+archive/ubuntu/lp1871129/+files/libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb sudo dpkg --install libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb sudo apt-mark hold libc6 #to avoid further update

Edit: /var/lib/dpkg/info/libc6:amd64.postinst and remove the sleep 1 that is in nearly the last line. then try.

PePoDev commented 4 years ago

From this command

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y --allow-downgrades
sudo apt-mark hold libc6

What's happen when Windows release update for this issue and How to rollback when Windows solved this ?

krodelabestiole commented 4 years ago

What's happen when Windows release update for this issue and How to rollback when Windows solved this ?

sudo apt-mark unhold libc6
sudo apt install ppa-purge
sudo ppa-purge ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt upgrade
PePoDev commented 4 years ago

Windows Build 1909 with fresh Ubuntu 20.04 install on WSL2 also had the same issue. Doing as @rafaeldtinoco proposed, fixed it for now.

1909 build has WSL 2 ? How you get it ?

feryardiant commented 4 years ago

1909 build has WSL 2 ? How you get it ?

@PePoDev Here https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

PePoDev commented 4 years ago

@feryardiant In normal Windows (Not Insider) OS build version is 18363. (11-May-20)

And WSL 2 require 18917

WSL 2 is only available in Windows 10 builds 18917 or higher

I don't think you can get it right now.

Except you are Insider.

danikhil commented 4 years ago

@feryardiant sign up for windows insider program to get insider build. Option available in setting> update & security. Avoid using on your main PC since, Preview builds are less stable.

feryardiant commented 4 years ago

I don't think you can get it right now.

Except you are Insider.

@PePoDev I am not saying we can have it in Stable build, right?

@feryardiant sign up for windows insider program to get insider build. Option available in setting> update & security. Avoid using on your main PC since, Preview builds are less stable.

@danikhil Thank you, that already stated in the link I posted above.

Also for those who for some reason "avoid" Insider build and don't want to doing hacky stuffs suggested by @Kagami above, Including me. The safest option we have is subscribe to this issue and back to Ubuntu 18.04 as @bkraul stated above and you can continue working.

gusflopes commented 4 years ago

Same problem here. Upgrading to WSL 2 is no option for me since I can't make Android Emulator on WSL2. I'm currently running Docker for Windows + Android Studio on Windows to develop in React Native... Althought Docker works with WSL 2, the Android Studio didn't work. Changed back to WSL 1 and now Docker won't install (WSL 1)... looks like I'll need to change back to Ubuntu 18.04 allso...

AllieUbisse commented 4 years ago

@onomatopellan in case if build-essential is installed it should be:

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y --allow-downgrades
sudo apt-mark hold libc6

to avoid g++ removal.

But otherwise it works fine, thanks to you and @rafaeldtinoco.

it worked !!!!!!!

max-hk commented 4 years ago

Guys, so what do I do if I have 18363 (WSL 1)build only and I need to use gpg? If I use Ubuntu 18.04 instead of 20.04 will it help? Or the only thing is a hack that is described above (by @rafaeldtinoco)

Try installing gnupg1, it works for me :)

sudo apt-get remove gpg
sudo apt-get install gnupg1

Source: https://github.com/MicrosoftDocs/WSL/issues/662#issuecomment-626680713

cynthiaxfu commented 4 years ago

I have the same issue. When I try this solution:

@onomatopellan in case if build-essential is installed it should be:

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y --allow-downgrades
sudo apt-mark hold libc6

to avoid g++ removal.

But otherwise it works fine, thanks to you and @rafaeldtinoco.

I get this error:

 Mitigation for WSL1 clock_realtime glibc issue:

BUG: https://bugs.launchpad.net/ubuntu/+source/htop/+bug/1871129
BUG: https://github.com/microsoft/WSL/issues/4898
 More info: https://launchpad.net/~rafaeldtinoco/+archive/ubuntu/lp1871129
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 http://ppa.launchpad.net/rafaeldtinoco/lp1871129/ubuntu focal InRelease
Get:5 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
Hit:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Err:5 https://dl.yarnpkg.com/debian stable InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 23E7166788B63E1E
Reading package lists... Done                                                                                               
W: GPG error: https://dl.yarnpkg.com/debian stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 23E7166788B63E1E
E: The repository 'https://dl.yarnpkg.com/debian stable InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Does anyone have a solution?

anandzhang commented 4 years ago

@onomatopellan in case if build-essential is installed it should be:

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1 -y --allow-downgrades
sudo apt-mark hold libc6

to avoid g++ removal.

But otherwise it works fine, thanks to you and @rafaeldtinoco.

Thank you !

onomatopellan commented 4 years ago

@cynthiaxfu Try this: curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

or follow this thread https://github.com/yarnpkg/yarn/issues/4453

bkraul commented 4 years ago

What's happen when Windows release update for this issue and How to rollback when Windows solved this ?

sudo apt-mark unhold libc6
sudo apt install ppa-purge
sudo ppa-purge ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt upgrade

This screws up libc6 big time. It cannot revert back to pre-rafaeldtinoco changes:

Fetched 5260 kB in 9s (573 kB/s)
Setting up libc6:amd64 (2.31-0ubuntu9) ...
sleep: cannot read realtime clock: Invalid argument
dpkg: error processing package libc6:amd64 (--configure):
 installed libc6:amd64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

To fix this you must do:

sudo rm -rf /var/lib/dpkg/info/libc6*
sudo apt install -f libc6
fabiomotta0311 commented 4 years ago

I resolved it removing the gpg and installing the gnupg1: sudo apt remove gpg sudo apt install gnupg1

bkraul commented 4 years ago

@fabiomotta0311 this approach removes a whole bunch of default packages:

 sudo apt remove gpg
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bolt dconf-gsettings-backend dconf-service gir1.2-packagekitglib-1.0 glib-networking glib-networking-common glib-networking-services gnupg-l10n gnupg-utils gpg-agent gpgsm gsettings-desktop-schemas libappstream4 libarchive13 libdconf1 libefiboot1 libefivar1 libfwupd2
  libfwupdplugin1 libgcab-1.0-0 libglib2.0-bin libgstreamer1.0-0 libgudev-1.0-0 libgusb2 libjson-glib-1.0-0 libjson-glib-1.0-common libpackagekit-glib2-18 libproxy1v5 libsmbios-c2 libsoup2.4-1 libstemmer0d libtss2-esys0 libxmlb1 packagekit packagekit-tools
  pinentry-curses sbsigntool secureboot-db tpm-udev unattended-upgrades
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  fwupd fwupd-signed gnupg gpg gpg-wks-client gpg-wks-server libgpgme11 python3-software-properties software-properties-common ubuntu-server
0 upgraded, 0 newly installed, 10 to remove and 0 not upgraded.
After this operation, 8758 kB disk space will be freed.
Do you want to continue? [Y/n]

I wonder what the implications are.

max-hk commented 4 years ago

bolt dconf-gsettings-backend dconf-service gir1.2-packagekitglib-1.0 glib-networking glib-networking-common glib-networking-services gnupg-l10n gnupg-utils gpg-agent gpgsm gsettings-desktop-schemas libappstream4 libarchive13 libdconf1 libefiboot1 libefivar1 libfwupd2 libfwupdplugin1 libgcab-1.0-0 libglib2.0-bin libgstreamer1.0-0 libgudev-1.0-0 libgusb2 libjson-glib-1.0-0 libjson-glib-1.0-common libpackagekit-glib2-18 libproxy1v5 libsmbios-c2 libsoup2.4-1 libstemmer0d libtss2-esys0 libxmlb1 packagekit packagekit-tools pinentry-curses sbsigntool secureboot-db tpm-udev unattended-upgrades

Those packages are dependency packages of gpg.

Because you removed gpg and they are not required by other installed packages, they will be automatically removed alongside gpg.

bkraul commented 4 years ago

Exactly, and some of those packages, like python3-software-properties software-properties-common ubuntu-server are system packages used for Ubuntu upgrade checking and install operations.

therealkenc commented 4 years ago

I gather the consensus here is that the problem is /dupe #4898, although in 41 posts there isn't a single strace(1) gist demonstrating a CLOCK_REALTIME EINVAL I could find. In Cyle's gist the clock_gettime() succeeds. Academic I guess; does not repro in WSL1 19631 on 20.04.

image

ghost commented 4 years ago

Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.

Thanks for your report!

oncet commented 4 years ago

Would love to know which one is the other issue.

dgellow commented 4 years ago

Yep, what is it duplicate of?

onomatopellan commented 4 years ago

The original issue and official response from the WSL team is https://github.com/microsoft/WSL/issues/4898#issuecomment-592196721

bkraul commented 4 years ago

How is that one a "duplicate",when it focuses on realtime clock, and this issue is specifically dealing with gpg? I understand the issues are "related" but I don't see how one is a duplicate of the order.

onomatopellan commented 4 years ago

It's a broken libc6 and it's used everywhere. Try looking for the shared libraries used by a binary: ldd $(which gpg) If you can see libc.so.6 then you probably will hit #4898

Edit: Ok now there is no doubt both issues are related: https://github.com/gpg/gnupg/blob/master/common/sysutils.c#L350

gpg uses nanosleep from glibc which right now is broken in Ubuntu 20.04 WSL1.

Andrei-Paul commented 4 years ago

Had the same issue with the kubernetes repo key; I chucked the key in /etc/apt/trusted.gpg.d, it worked and I moved on.

bkraul commented 4 years ago

Windows 10 2004 came out 2 days ago. With this, WSL2 is now widely available. I upgraded my ubuntu WSL instance to WSL2, and everything works as expected.