WSL: snapd does not work inside WSL
Version
10.0.22621.674
WSL Version
- WSL 2
- WSL 1
Kernel Version
5.15.68.1
Distro Version
Ubuntu 22.10
Other Software
No response
Repro Steps
Run systemctl --failed
Expected Behavior
Functional snapd service
Actual Behavior
toor@XPS:~$ systemctl status snapd
● snapd.service - Snap Daemon
Loaded: loaded (/lib/systemd/system/snapd.service; enabled; preset: enabled)
Active: active (running) since Sun 2022-10-16 17:42:14 PDT; 3min 9s ago
TriggeredBy: ● snapd.socket
Main PID: 181 (snapd)
Tasks: 11 (limit: 4697)
Memory: 44.6M
CGroup: /system.slice/snapd.service
└─181 /usr/lib/snapd/snapd
Oct 16 17:42:14 XPS systemd[1]: Starting Snap Daemon...
Oct 16 17:42:14 XPS snapd[181]: AppArmor status: apparmor not enabled
Oct 16 17:42:14 XPS snapd[181]: overlord.go:263: Acquiring state lock file
Oct 16 17:42:14 XPS snapd[181]: overlord.go:268: Acquired state lock file
Oct 16 17:42:14 XPS snapd[181]: daemon.go:247: started snapd/2.57.4+22.10ubuntu1 (series 16; classic; devmode; wsl) ubuntu/22.10 (amd64) linux/5.15.68.1-microsoft-stand.
Oct 16 17:42:14 XPS snapd[181]: main.go:129: system does not fully support snapd: snapd does not work inside WSL
Oct 16 17:42:14 XPS snapd[181]: daemon.go:340: adjusting startup timeout by 55s (pessimistic estimate of 30s plus 5s per snap)
Oct 16 17:42:14 XPS systemd[1]: Started Snap Daemon.
toor@XPS:~$ snap list
Interacting with snapd is not yet supported on Windows Subsystem for Linux.
This command has been left available for documentation purposes only.
Diagnostic Logs
No response
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 24 (1 by maintainers)
Commits related to this issue
- Switch from installations via snap Ubuntu snaps do not work in WSL 2. https://github.com/microsoft/WSL/issues/9026 https://github.com/microsoft/WSL/issues/8709 — committed to conradhodge/win-dev by conradhodge 3 years ago
- Switch from installations via snap Ubuntu snaps do not work in WSL 2. https://github.com/microsoft/WSL/issues/9026 https://github.com/microsoft/WSL/issues/8709 — committed to conradhodge/win-dev by conradhodge 3 years ago
There is a fix for this in the beta channel of snapd. Problem being that you cannot update to beta because snap won’t let you.
If you manage to make snap work temporarily (e.g. disabling interop or reverting to an older version via apt), you can use either command (try the first one, if it fails try the second one):
Then you can undo your temporary fix (e.g. enabling interop again or doing apt upgrade).
For a more step-by-step explanation (following @cerebrate 's trick of disabling interop): https://github.com/ubuntu/WSL/issues/299#issuecomment-1285083475
The issue still affects users in WSL2 that use Ubuntu 22.10. (See here to check out the status of the fix). I believe the issue should stay open until
snapd 2.57.5+22.10is released.Workaround that keeps WSL Interop active:
Ensure you have
systemd-binfmt.serviceinstalled in your distro (in Ubuntu that means having thebinfmt-supportpackage installed via apt), then execute the following:This will replace the
WSLInteropbinfmt support with an identical configuration under a different name. To activate this, leave WSL and runwsl --shutdownin a PowerShell or CMD window. Next time you restart your distro it should replace theWSLInteropbinfmt configuration with this renamed copy so thatsnapdcan’t tell that it’s on WSL.Yeah, it’s kind of a long story. Way back when, snapd implemented a test to see if it was running under WSL, but that test, it turned out, had a bug which meant that it only detected WSL 1, so for a very long time, you were able to get snapd working under WSL 2 if you fixed the prerequisites that stopped it from doing so.
(I don’t think any of us who got snapd working even noticed the test was there.)
Then along came snapcore/snapd#12135, which fixed the WSL detection bug so the test actually worked, and snapd stopped working.
The good news is that WSL detection post that PR works by looking for
/proc/sys/fs/binfmt_misc/WSLInterop, so you can enable snapd at the cost of disabling Windows interop. (Note: not using the/etc/wsl.confmethod, because that leaves the binfmt in place; rather, as root, runecho -1 >> /proc/sys/fs/binfmt_misc/WSLInterop, which removes the binfmt handler. Then restart all snapd services.)The better news is that there’s a PR which acknowledges this stuff over at snapcore/snapd#12179, which has been merged, so we should be good once snapd 2.57.5 hits.
This issue now considered solved from the Ubuntu team’s point of view.
snapd 2.57.5+22.10has been released on kinetic, you can fix it with:The permanent fix has been released for Ubuntu 18.04, 20.04 and 22.04. It’ll soon reach 22.10 as well. Here is the fix:
https://github.com/ubuntu/WSL/issues/299#issuecomment-1291650396
Yes, they’ll need to return to the stable channel. I added it to the linked comment.
I also suddenly couldn’t use the snap command as well, it worked for a while after updating WSL2 to 0.7.0, but today it was not working anymore.
No, it’ll be on kinetic-updates. Form the
/etc/apt/sources.listfile:kinetic-updates contains bug fixes (such as this one). Both ppa are enabled on your distro by default so simply do
apt update && apt upgradeand this problem will be solved.@circleupx
Ahh, then your original problem was simply because Systemd is not supported under Windows 10 anyway. As the announcement mentioned, Systemd support requires WSL 0.67.6 or later, which is only available for Windows 11! 😀
I had the systemd=true in the WSL, though snap list never yielded any results. I decide to take another route, I upgraded to Windows 11. Reinstalled everything following the guidelines listed here and on various posts by Microsoft and I am happy to say.
It is working!!!
Thank you.
I’ve tried the permanent fix mentioned WSL#299 but I still can’t get it to work. At first, I was getting the message posted in this issue.
I decided to nuke the distro and start over, then it turned into this message.
Snapd version
Distro version
Windows Build Version 10.0.19045 Build 19045
Does anyone have any suggestions?