Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
penavincent opened this issue Apr 24, 2020 · 164 comments
Closed

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

penavincent opened this issue Apr 24, 2020 · 164 comments

Comments

@penavincent
Copy link

penavincent commented Apr 24, 2020

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
@sirredbeard
Copy link
Contributor

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.

@jmoeyersons
Copy link

Is there any update about this issue available please?

@blackliner
Copy link

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

@jramiresbrito
Copy link

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

Updates are welcome.

@fenris
Copy link

fenris commented Jun 17, 2020

any update on this?

@mdtalhachy
Copy link

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

snap 2.42.1+18.04
snapd unavailable
series -

@sunliusi
Copy link

sunliusi commented Jul 4, 2020

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

@obeyda
Copy link

obeyda commented Jul 17, 2020

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?

@adv27
Copy link

adv27 commented Aug 14, 2020

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!

@troseman
Copy link

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

@manuelvizir
Copy link

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

@mahfuzullah
Copy link

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

@ride4sun
Copy link

ride4sun commented Sep 30, 2020

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?

@ethercflow
Copy link

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+

@SamLowryMOI
Copy link

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.

@ethercflow
Copy link

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.

@SamLowryMOI
Copy link

@ethercflow Thanks!

@zarinfam
Copy link

zarinfam commented Oct 2, 2020

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.

@RobertBernstein
Copy link

RobertBernstein commented Oct 26, 2020

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?

@VictorNanka
Copy link

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

@theofaron
Copy link

Did you replace the placeholders with your values? You need to execute the first two commands. Then use top (or htop) to find out the PID of systemd and then use it to replace the $(pidof systemd) in the third command and replace $LOGNAME with your login name.

@Laxman-SM
Copy link

@theofaron thanks for the Hack,

@RobertBernstein
Copy link

Did you replace the placeholders with your values? You need to execute the first two commands. Then use top (or htop) to find out the PID of systemd and then use it to replace the $(pidof systemd) in the third command and replace $LOGNAME with your login name.

Yes, I have tried it with the actual PID replacing the $(pidof systemd) and my username (rob) in place of the $LOGNAME. It had the same result. I also shutdown WSL 2 with wsl --shutdown and then tried again; I got the same result. I would love any further help with this. Thanks!

@SamLowryMOI
Copy link

I use this under Ubuntu 20.04.1 LTS. Maybe it doesn't work under Pengwin. Maybe you make a mistake. I'll show you my approach. Please reboot your pc to get a clean start point. I use the new terminal in windows.

The first command shows some output, no errors, ends with 'done'.
The second and third command show no output.
snap version and snap list work fine. No need to use snap login.

Ensure you use the right PID. After the second command use htop. Use F10 to filter the output. Type systemd. There are about eleven entries. Type a space (so you are filtering for 'systemd ', not for 'systemd'). Now there are only two entries. Use the pid for /lib/systemd/systemd.

If you done it all right I can't help you, it seems to be a problem with Pengwin, sorry.

@benmccann
Copy link

https://github.com/arkane-systems/genie looks to be another workaround for this issue

@lxg208
Copy link

lxg208 commented Nov 21, 2020

I have a strange problem, after running

sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.targe

my host name changed. It went from "TEST_server" to "TESTserver". What did I do wrong?

@jsanzdev
Copy link

jsanzdev commented Dec 8, 2020

The workaround doesn't work for me, I get stuck with the snap login, is there any solutions?

@jepperaskdk
Copy link

I have systemd=true in /etc/wsl.conf, and I had snap working briefly. Now I get:

Interacting with snapd is not yet supported on Windows Subsystem for Linux.
This command has been left available for documentation purposes only.

@andrewachen
Copy link

I have systemd=true in /etc/wsl.conf, and I had snap working briefly. Now I get:

Interacting with snapd is not yet supported on Windows Subsystem for Linux.
This command has been left available for documentation purposes only.

Looks like this is being discussed here: ubuntu/WSL#299

@MatanYemini
Copy link

@EduardGomezEscandell
Copy link

I have systemd=true in /etc/wsl.conf, and I had snap working briefly. Now I get:

Interacting with snapd is not yet supported on Windows Subsystem for Linux.
This command has been left available for documentation purposes only.

For anyone having this issue, an official fix is out:
ubuntu/WSL#299 (comment)

@Archsx
Copy link

Archsx commented Nov 8, 2022

I have systemd=true in /etc/wsl.conf, and I had snap working briefly. Now I get:

Interacting with snapd is not yet supported on Windows Subsystem for Linux.
This command has been left available for documentation purposes only.

For anyone having this issue, an official fix is out: ubuntu/WSL#299 (comment)

Hi, I've use the way you mentioned in the link, but I still got the error:

~$ sudo snap install kotlin --classic
error: cannot communicate with server: Post http://localhost/v2/snaps/kotlin: dial unix /run/snapd.socket: connect: no such file or directory

what I have done:
1>add the code below to /etc/wsl.conf (it is not existed before so I create one)

[boot]
systemd=true

I'm using windows 10 22H2 19045.2006 and ubuntu version is 20.04 LTS

here is some info if needed:

snap -info

$ snap -info

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x5569213b8275]

goroutine 1 [running]:
main.main.func1()
        /build/snapd-5gfOVK/snapd-2.57.5+20.04/cmd/snap/main.go:492 +0x95
panic(0x55692185d9c0, 0x556921ed8780)
        /usr/lib/go-1.13/src/runtime/panic.go:679 +0x1b6
main.run(0xc0003f7db8, 0xe)
        /build/snapd-5gfOVK/snapd-2.57.5+20.04/cmd/snap/main.go:559 +0x375
main.main()
        /build/snapd-5gfOVK/snapd-2.57.5+20.04/cmd/snap/main.go:497 +0x371

snap version

snap                         2.57.5+20.04
snapd                        unavailable
series                       16
Windows Subsystem for Linux  -
kernel                       5.10.102.1-microsoft-standard-WSL2 (amd64)

@SamLowryMOI
Copy link

[boot]
systemd=true

I'm using windows 10 22H2 19045.2006 and ubuntu version is 20.04 LTS

I may be wrong, but as far as I understand it, this only works on Windows 11.

@EduardGomezEscandell
Copy link

I'm using windows 10 22H2 19045.2006 and ubuntu version is 20.04 LTS

Snap needs systemd to work. Systemd support on WSL is only available on Windows 11.

@viceice
Copy link

viceice commented Nov 8, 2022

You need the store WSL version and you should use ubuntu 22.04 which works out of the box

@Archsx
Copy link

Archsx commented Nov 8, 2022

You need the store WSL version and you should use ubuntu 22.04 which works out of the box

Hello,what you mean store WSL version ? here is the wsl --status output if needed:

Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS

@SamLowryMOI
Copy link

@Archsx

Hello,what you mean store WSL version ?

looks like WSL now officially supports systemd: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/

Did you read this?

@Archsx
Copy link

Archsx commented Nov 8, 2022

@Archsx

Hello,what you mean store WSL version ?

looks like WSL now officially supports systemd: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/

Did you read this?

@Archsx

Hello,what you mean store WSL version ?

looks like WSL now officially supports systemd: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/

Did you read this?

oops, it seems that I need to upgrade to windows 11 after I read that post . thanks anyway

@EduardGomezEscandell
Copy link

You need the store WSL version and you should use ubuntu 22.04 which works out of the box

Note that Ubuntu 22.04 still requires the whole /etc/wsl.conf thing to enable systemd. For a trully out-of-the-box, no-steps-required experience use Ubuntu-Preview. It also fixes a couple services that fail on WSL.

@vineethsankre
Copy link

exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

When I tried to execute this command,
nsenter: failed to execute 69: No such file or directory

[process exited with code 127 (0x0000007f)]

@zstadler
Copy link

zstadler commented Dec 10, 2022

Systemd support is now available in WSL!

I followed the simple instruction in the above article, and sudo snap install firefox worked like charm!

My /etc/wsl.conf file includes just 2 lines:

[boot]
systemd=true

@ArthurKun21
Copy link

Systemd support is now available in WSL!

I followed the simple instruction in the above article, and sudo snap install firefox worked like charm!

My /etc/wsl.conf file includes just 2 lines:

[boot]
systemd=true

can confirm this works!

@LeCyberDucky
Copy link

For what it's worth, I'm using Windows 10, build 19044.2364, and I was able to install Firefox via Snap after doing wsl --update.

@faribauc
Copy link

For what it's worth, I'm using Windows 10, build 19044.2364, and I was able to install Firefox via Snap after doing wsl --update.

Confirming this works on Windows 10 :)

@VaderFuntime
Copy link

Systemd support is now available in WSL!

I followed the simple instruction in the above article, and sudo snap install firefox worked like charm!

My /etc/wsl.conf file includes just 2 lines:

[boot]
systemd=true

Only thing that worked for me!! thanks!

@mustafa-guner
Copy link

Systemd support is now available in WSL!

I followed the simple instruction in the above article, and sudo snap install firefox worked like charm!

My /etc/wsl.conf file includes just 2 lines:

[boot]
systemd=true

March 2023 - Still works like a charm! Thanks!

@zpeng2022
Copy link

works! Thx a lot!

@chucamphong
Copy link

chucamphong commented Apr 1, 2023

Systemd support is now available in WSL!
I followed the simple instruction in the above article, and sudo snap install firefox worked like charm!
My /etc/wsl.conf file includes just 2 lines:

[boot]
systemd=true

March 2023 - Still works like a charm! Thanks!

It works, thanks a lot ❤️

@mmiric-endava
Copy link

Exited wsl and ran wsl --update in Powershell. Docker installed with snap after that with no issues.

@krave1986
Copy link

@mmiric-endava Do you have more info about wsl --update? Any docs maybe.

@mmiric-endava
Copy link

@mmiric-endava Do you have more info about wsl --update? Any docs maybe.

Yes, there are some details displayed by wsl --help and on Microsoft docs as well:

Update your WSL version to the latest version. Options include:

--web-download: Download the latest update from the GitHub rather than the Microsoft Store.

Essentially your wsl package is updated to the latest version.

@mickdewald
Copy link

Important:
Do not forget to exit wsl via wsl --shutdown after editing /etc/wsl.conf
Just exiting wsl via exit and entering via wsl is not enough

@cbouwense
Copy link

I went through all the steps outlined on this article Systemd support is now available in WSL! and it did not work. However I was doing this from a VSCode terminal running WSL. I opened a "normal" wsl window and it worked like a charm (Windows 10).

@gal-dahan
Copy link

Hi everyone I try install k9s on WSL in that way:
curl -LO https://github.com/derailed/k9s/releases/latest/download/k9s_Linux_x86_64
I go to /etc/wsl.conf and i have
[boot] systemd=true
after that, I do the command
k9s
and I get:
/usr/local/bin/k9s: 1: Not: not found

@Diom
Copy link

Diom commented May 9, 2024

I went through all the steps outlined on this article Systemd support is now available in WSL! and it did not work. However I was doing this from a VSCode terminal running WSL. I opened a "normal" wsl window and it worked like a charm (Windows 10).

I also tried most of the solutions documented here. ^THIS prompted me, in a not very hopeful way, to try switching from Windows Terminal + Pwsh + wsl to use the WSL console.... and it worked. I am not sure how I feel about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests