WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL2- Ubuntu 20.04 Snap store doesn't work due to systemd dependency

Open penavincent opened this issue 6 years ago • 164 comments

I just reinstalled ubuntu on WSL2 from scratch in order to upgrade to 20.04 with a clean slate. The main issue I've noticed has to do with a lot of packages moving to snap rather than being maintained on apt, which is how I imagine most people here install their packages.

In fact it seems like Ubuntu 20.04 LTS replaced the ubuntu software with snapcraft entirely. So it's obvious snap is becoming the 'default' of the distro.

The issue is that snap doesn't currently seem to work on wsl2 due to it's reliance on systemd. If I understand it correctly, the snapd service should be running in the background for it to work, which snapd already comes preinstalled, however snapd can't start due to WSL2 not having systemd.

So if I run the command snap find node for example, it gives me the following error message:

error: cannot communicate with server: Post http://localhost/v2/snaps/hello-world: dial unix /run/snapd.socket: connect: no such file or directory

Running the command sudo service snapd start simply responds with:

snapd: unrecognized service

However snapd is already installed.

Is there any plan to get this working in the future, or is it something that is in progress?

In my development flow, I like to use the chromium-browser on WSL2 with the X410 server in order to test my web apps in both Windows and Linux browsers, since they can reveal some bugs, like say, when uploading csv files files from a Windows browser, React can't really tell since Windows changes the MIME Type of the file, whereas Linux and Mac keep it the same and so it's easy to handle.

Now I can't really use chromium though, since I can't install it without snap anymore.

EDIT: After several hours of trying to fix it I came across several other issues from about 8-10 months ago, with the most popular solution being this, which seems to make some changed to PIDs to make it work, but it just seems so hacky, and it's not a permanent solution, as a restart will remove it.

  • Windows Version: 10.0.19613.1000
  • Ubuntu 20.04 WSL2

penavincent avatar Apr 24 '20 01:04 penavincent

This is something that is being looked at.

Implementing in a non-hacky way that can be supported long-term without a lot of secondary issues takes planning.

There is a workaround to get snaps working.

sirredbeard avatar Apr 24 '20 01:04 sirredbeard

Is there any update about this issue available please?

jmoeyersons avatar Jun 02 '20 09:06 jmoeyersons

Here is the link to the scripted version of the workaround @sirredbeard mentioned: https://github.com/DamionGans/ubuntu-wsl2-systemd-script

blackliner avatar Jun 06 '20 10:06 blackliner

Running on same error when trying to run snaps to download heroku cli.

Updates are welcome.

jramiresbrito avatar Jun 08 '20 23:06 jramiresbrito

any update on this?

fenris avatar Jun 17 '20 16:06 fenris

Still not working. When I run snap version, this appears:

snap 2.42.1+18.04 snapd unavailable series -

mdtalhachy avatar Jul 03 '20 07:07 mdtalhachy

just try:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

snap version

sunliusi avatar Jul 04 '20 03:07 sunliusi

just try:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

snap version

That worked for me :), but i don't understand why, can anyone explain please?

obeyda avatar Jul 17 '20 20:07 obeyda

just try:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

snap version

Your script worked flawlessly, many thanks!

adv27 avatar Aug 14 '20 04:08 adv27

That worked for me :), but i don't understand why, can anyone explain please?

see https://discourse.ubuntu.com/t/using-snapd-in-wsl2/12113

troseman avatar Aug 14 '20 04:08 troseman

not working, always shows error: access denied (see 'snap help login') when trying to install or login

manuelvizir avatar Aug 26 '20 17:08 manuelvizir

not working, always shows error: access denied (see 'snap help login') when trying to install or login

just login to your snap account/ ubuntu one account using snap login [email protected] command

mahfuzullah avatar Sep 15 '20 04:09 mahfuzullah

just try:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

snap version

I tried that on kali and it did not work. It basically kills the bash on the third command and I am back in the Powershell. Is there an official ETA to really fix that?

ride4sun avatar Sep 30 '20 17:09 ride4sun

just try:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

snap version

Thanks! Works for me!

➜  ~ snap version
snap    2.46.1+20.04
snapd   2.46.1+20.04
series  16
ubuntu  20.04
kernel  5.8.3-microsoft-standard+

ethercflow avatar Oct 01 '20 12:10 ethercflow

Works for me, too. But I get

snap version
snap    2.46.1+20.04
snapd   2.46.1+20.04
series  16
ubuntu  20.04
kernel  4.19.128-microsoft-standard

Anyone knows why I get another kernel version (4.19.128-microsoft-standard instead 5.8.3-microsoft-standard+)? Using wsl2 on Windows 10 Home, 2004, Version 10.0.19041.508.

SamLowryMOI avatar Oct 01 '20 13:10 SamLowryMOI

Works for me, too. But I get

snap version
snap    2.46.1+20.04
snapd   2.46.1+20.04
series  16
ubuntu  20.04
kernel  4.19.128-microsoft-standard

Anyone knows why I get another kernel version (4.19.128-microsoft-standard instead 5.8.3-microsoft-standard+)? Using wsl2 on Windows 10 Home, 2004, Version 10.0.19041.508.

@SamLowryMOI Oh, I compiled by myself to test BPF.

ethercflow avatar Oct 01 '20 13:10 ethercflow

@ethercflow Thanks!

SamLowryMOI avatar Oct 01 '20 13:10 SamLowryMOI

not working, always shows error: access denied (see 'snap help login') when trying to install or login

@mahfuzullah I had this problem. I executed wsl --shutdown from windows cmd and then executed those commands again. Now without any login, everything works perfectly.

zarinfam avatar Oct 02 '20 11:10 zarinfam

just try: sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME snap version

I tried that on kali and it did not work. It basically kills the bash on the third command and I am back in the Powershell. Is there an official ETA to really fix that?

I had the same problem in Pengwin under WSL2, but before it exits the shell, I get the following message:

nsenter: cannot open /proc/1189/ns/time: No such file or directory

However, running snap version show valid information. Now when I run sudo snap list, I get:

error: access denied (see 'snap help login')

When I run sudo snap login <email>, I get error: access denied (see 'snap help login').

Any ideas?

RobertBernstein avatar Oct 26 '20 02:10 RobertBernstein

just try: sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME snap version

I tried that on kali and it did not work. It basically kills the bash on the third command and I am back in the Powershell. Is there an official ETA to really fix that?

I had the same problem in Pengwin under WSL2, but before it exits the shell, I get the following message:

nsenter: cannot open /proc/1189/ns/time: No such file or directory

However, running snap version show valid information. Now when I run sudo snap list, I get:

error: access denied (see 'snap help login')

When I run sudo snap login <email>, I get error: access denied (see 'snap help login').

Any ideas?

same problem

VictorNanka avatar Oct 26 '20 07:10 VictorNanka