Repository navigation
Description
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
Activity
sirredbeard commentedon Apr 24, 2020
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 commentedon Jun 2, 2020
Is there any update about this issue available please?
blackliner commentedon Jun 6, 2020
Here is the link to the scripted version of the workaround Hayden Barnes (@sirredbeard) mentioned: https://github.com/DamionGans/ubuntu-wsl2-systemd-script
jramiresbrito commentedon Jun 8, 2020
Running on same error when trying to run snaps to download heroku cli.
Updates are welcome.
fenris commentedon Jun 17, 2020
any update on this?
mdtalhachy commentedon Jul 3, 2020
Still not working. When I run
snap version, this appears:snap 2.42.1+18.04
snapd unavailable
series -
sunliusi commentedon 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 commentedon Jul 17, 2020
That worked for me :), but i don't understand why, can anyone explain please?
adv27 commentedon Aug 14, 2020
Your script worked flawlessly, many thanks!
troseman commentedon Aug 14, 2020
see https://discourse.ubuntu.com/t/using-snapd-in-wsl2/12113
manuelvizir commentedon Aug 26, 2020
not working, always shows
error: access denied (see 'snap help login')when trying to install or loginmahfuzullah commentedon Sep 15, 2020
just login to your snap account/ ubuntu one account using
snap login [email protected]commandride4sun commentedon Sep 30, 2020
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 commentedon Oct 1, 2020
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 commentedon Oct 1, 2020
Works for me, too. But I get
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.
137 remaining items
zstadler commentedon Dec 10, 2022
Systemd support is now available in WSL!
I followed the simple instruction in the above article, and
sudo snap install firefoxworked like charm!My
/etc/wsl.conffile includes just 2 lines:ArthurKun21 commentedon Dec 13, 2022
can confirm this works!
LeCyberDucky commentedon Dec 28, 2022
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 commentedon Dec 29, 2022
Confirming this works on Windows 10 :)
VaderFuntime commentedon Jan 26, 2023
Only thing that worked for me!! thanks!
mustafa-guner commentedon Mar 15, 2023
March 2023 - Still works like a charm! Thanks!
zpeng2022 commentedon Mar 27, 2023
works! Thx a lot!
fengzjin commentedon Apr 1, 2023
It works, thanks a lot ❤️
mmiric-endava commentedon Apr 25, 2023
Exited wsl and ran
wsl --updatein Powershell. Docker installed with snap after that with no issues.krave1986 commentedon Apr 26, 2023
Milos Miric (@mmiric-endava) Do you have more info about
wsl --update? Any docs maybe.mmiric-endava commentedon Apr 26, 2023
Yes, there are some details displayed by
wsl --helpand 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 commentedon May 7, 2023
Important:
Do not forget to exit wsl via
wsl --shutdownafter editing/etc/wsl.confJust exiting wsl via
exitand entering viawslis not enoughcbouwense commentedon Jun 19, 2023
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 commentedon Aug 11, 2023
Hi everyone I try install k9s on WSL in that way:
curl -LO https://github.com/derailed/k9s/releases/latest/download/k9s_Linux_x86_64I go to
/etc/wsl.confand i have[boot] systemd=trueafter that, I do the command
k9s
and I get:
/usr/local/bin/k9s: 1: Not: not foundDiom commentedon May 9, 2024
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 + wslto use theWSL console.... and it worked. I am not sure how I feel about it.