Skip to content

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

Closed

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

  1. sirredbeard commented on Apr 24, 2020

    @sirredbeard
    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.

  2. jmoeyersons commented on Jun 2, 2020

    @jmoeyersons

    Is there any update about this issue available please?

  3. blackliner commented on Jun 6, 2020

    @blackliner
  4. jramiresbrito commented on Jun 8, 2020

    @jramiresbrito

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

    Updates are welcome.

  5. fenris commented on Jun 17, 2020

    @fenris

    any update on this?

  6. mdtalhachy commented on Jul 3, 2020

    @mdtalhachy

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

    snap 2.42.1+18.04
    snapd unavailable
    series -

  7. sunliusi commented on Jul 4, 2020

    @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

  8. obeyda commented on Jul 17, 2020

    @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

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

  9. adv27 commented on Aug 14, 2020

    @adv27

    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!

  10. troseman commented on Aug 14, 2020

    @troseman

    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

  11. manuelvizir commented on Aug 26, 2020

    @manuelvizir

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

  12. mahfuzullah commented on Sep 15, 2020

    @mahfuzullah

    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

  13. ride4sun commented on Sep 30, 2020

    @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

    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?

  14. ethercflow commented on Oct 1, 2020

    @ethercflow

    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+
  15. SamLowryMOI commented on Oct 1, 2020

    @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.

  16. 137 remaining items

  17. zstadler commented on Dec 10, 2022

    @zstadler

    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
    
  18. ArthurKun21 commented on Dec 13, 2022

    @ArthurKun21

    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!

  19. LeCyberDucky commented on Dec 28, 2022

    @LeCyberDucky

    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.

  20. faribauc commented on Dec 29, 2022

    @faribauc

    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 :)

  21. VaderFuntime commented on Jan 26, 2023

    @VaderFuntime

    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!

  22. mustafa-guner commented on Mar 15, 2023

    @mustafa-guner

    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!

  23. zpeng2022 commented on Mar 27, 2023

    @zpeng2022

    works! Thx a lot!

  24. fengzjin commented on Apr 1, 2023

    @fengzjin

    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 ❤️

  25. mmiric-endava commented on Apr 25, 2023

    @mmiric-endava

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

  26. krave1986 commented on Apr 26, 2023

    @krave1986

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

  27. mmiric-endava commented on Apr 26, 2023

    @mmiric-endava

    Milos Miric (@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.

  28. mickdewald commented on May 7, 2023

    @mickdewald

    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

  29. cbouwense commented on Jun 19, 2023

    @cbouwense

    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).

  30. gal-dahan commented on Aug 11, 2023

    @gal-dahan

    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

  31. Diom commented on May 9, 2024

    @Diom

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions