WSL2- Ubuntu 20.04 Snap store doesn't work due to systemd dependency
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
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.
Is there any update about this issue available please?
Here is the link to the scripted version of the workaround @sirredbeard mentioned: https://github.com/DamionGans/ubuntu-wsl2-systemd-script
Running on same error when trying to run snaps to download heroku cli.
Updates are welcome.
any update on this?
Still not working. When I run snap version, this appears:
snap 2.42.1+18.04 snapd unavailable series -
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
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?
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!
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
not working, always shows error: access denied (see 'snap help login') when trying to install or login
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
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?
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+
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.
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-standardAnyone 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 Thanks!
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.
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?
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 directoryHowever, running
snap versionshow valid information. Now when I runsudo snap list, I get:
error: access denied (see 'snap help login')When I run
sudo snap login <email>, I geterror: access denied (see 'snap help login').Any ideas?
same problem