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

[snapd 2.57.4] Snap Suddenly Stop Working on SystemD Enabled WSL2 #299

Closed
1 task
arinanto opened this issue Oct 19, 2022 · 25 comments
Closed
1 task

[snapd 2.57.4] Snap Suddenly Stop Working on SystemD Enabled WSL2 #299

arinanto opened this issue Oct 19, 2022 · 25 comments
Assignees

Comments

@arinanto
Copy link

cmd /c ver

Microsoft Windows [Version 10.0.22621.674]

wsl --status

Default Distribution: AlmaLinux-8
Default Version: 2

Did the problem occur during installation?

  • Yes

What happened?

Even when previously able to install microk8s using sudo snap install microk8s --classic it's now suddenly stopped working. This render microk8s stop command unable to execute and emit

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

messages.

What was expected?

Able to install, start, stop. and uninstall using Snap when systemd is enabled on WSL2.

Steps to reproduce

  1. Enable systemd support on WSL2 /etc/wsl.conf
    [boot]
    systemd=true
    
  2. Restart using wsl --shutdown
  3. Install microk8s
  4. Run microk8s start
  5. Run microk8s stop (usually works fine, this time it stops working)

Additional information

wsl --version

WSL version: 0.70.0.0
Kernel version: 5.15.68.1
WSLg version: 1.0.45
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.674

cat /etc/wsl.conf

[boot]
systemd=true

[automount]
options = ro

Additional screenshot

snapd failed

@EduardGomezEscandell EduardGomezEscandell self-assigned this Oct 19, 2022
@EduardGomezEscandell
Copy link
Collaborator

Hi, thanks for your report.

This is a known issue (https://bugs.launchpad.net/snapd/+bug/1991826). A fix has already been comited here snapcore/snapd#12179 but it hasn't reached users yet. We're also working on a work-around.

May I ask what release you're running? ($ lsb_release -a).

@cdgh2021
Copy link

is there a release schedule of this fix?
btw I use ubuntu 22.04.1

@EduardGomezEscandell
Copy link
Collaborator

EduardGomezEscandell commented Oct 20, 2022

Judging from past releases it should be in the next couple of weeks.

Update: there is a less destructive fix, see next comment

Here is a temporary fix that works for Ubuntu 22.04. Note that this will uninstall all your snaps, so be sure to make any necessary backups.

First, make sure your install is indeed broken:

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

If so, apply the fix:

$ sudo apt -y remove snapd --purge # This is the destructive action
$ sudo apt install -y snapd=2.55.3+22.04
$ sudo snap install snapd --beta   # Should install snapd (beta) 2.57.5
$ sudo snap refresh                # Validation: should not print the same as before
$ sudo apt upgrade snapd          # No need to stay in old version

@EduardGomezEscandell
Copy link
Collaborator

EduardGomezEscandell commented Oct 20, 2022

This explanation is deprecated for all but Ubuntu Preview (Ubuntu 22.10). Check out #299 (comment) for a simple two-line permanent fix.


First, make sure your install is indeed broken:

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

If so, apply the fix. Go into powershell:

# Check the name of the distro you want to fix.
wsl -l -v
  NAME              STATE           VERSION
* Ubuntu-20.04      Running         2
  Ubuntu-Preview    Stopped         2
  Ubuntu-18.04      Stopped         2
  Ubuntu            Stopped         2
  Ubuntu-22.04      Running         2

# Use the name of the distro that you want to fix:
wsl -d NAME -u root
# For instance: wsl -d Ubuntu -u root

This will start a shell as root:

echo -1 >> /proc/sys/fs/binfmt_misc/WSLInterop
systemctl restart snapd
snap refresh snapd --beta
exit

You'll be back in powershell. Restart wsl:

wsl --shutdown

Go into WSL the usual way and test that it worked:

sudo snap refresh
# Should print something other that the previous message

@arinanto
Copy link
Author

Can confirm the latest workaround works, thank you. Any way I can return to snap release once the fix is there?

Hi, thanks for your report.

This is a known issue (https://bugs.launchpad.net/snapd/+bug/1991826). A fix has already been comited here snapcore/snapd#12179 but it hasn't reached users yet. We're also working on a work-around.

May I ask what release you're running? ($ lsb_release -a).

Also, here's my lsb_release -a in case it's still needed.

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

@EduardGomezEscandell
Copy link
Collaborator

Thanks, I've checked and this afects every distro from 18.04 to 22.10.

Any way I can return to snap release once the fix is there?

Yes, once the fix is available you'll be able to return to release. I'll mention it in this thread and close the issue once that is the case.

@lucyllewy
Copy link

lucyllewy commented Oct 23, 2022

Workaround:

Ensure you have systemd-binfmt.service installed in your distro (in Ubuntu that means having the binfmt-support package installed via apt), then execute the following:

echo ":windowsexe:M::\x4d\x5a::/init:PF" | sudo tee -a /etc/binfmt.d/windowsexe.conf

This will replace the WSLInterop binfmt support with an identical configuration under a different name. To activate this, leave WSL and run wsl --shutdown in a PowerShell or CMD window. Next time you restart your distro it should replace the WSLInterop binfmt configuration with this renamed copy so that snapd can't tell that it's on WSL.

Edit: fix the path to the configuration file.

@EduardGomezEscandell
Copy link
Collaborator

EduardGomezEscandell commented Oct 26, 2022

This is the official, permanent fix.

This is the fix:

sudo apt-get -y update
sudo apt-get -y upgrade snapd

If you had switched to the beta channel as a temporary fix, you can undo it via:

sudo snap refresh snapd --channel=stable

@EduardGomezEscandell EduardGomezEscandell changed the title Snap Suddenly Stop Working on SystemD Enabled WSL2 [snap 2.57.4] Snap Suddenly Stop Working on SystemD Enabled WSL2 Oct 26, 2022
@EduardGomezEscandell EduardGomezEscandell changed the title [snap 2.57.4] Snap Suddenly Stop Working on SystemD Enabled WSL2 [snapd 2.57.4] Snap Suddenly Stop Working on SystemD Enabled WSL2 Oct 26, 2022
@edmondium
Copy link

Workaround:

Ensure you have systemd-binfmt.service installed in your distro (in Ubuntu that means having the binfmt-support package installed via apt), then execute the following:

echo ":windowsexe:M::\x4d\x5a::/init:PF" | sudo tee -a /etc/binfmt.d/windowsexe.conf

This will replace the WSLInterop binfmt support with an identical configuration under a different name. To activate this, leave WSL and run wsl --shutdown in a PowerShell or CMD window. Next time you restart your distro it should replace the WSLInterop binfmt configuration with this renamed copy so that snapd can't tell that it's on WSL.

Edit: fix the path to the configuration file.

It triggers some errors when I run jupyter lab:
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
WSL Interopability is disabled. Please enable it before using WSL.
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
[error] WSL Interoperability is disabled. Please enable it before using WSL.
Parameter format not correct - ""
tcgetpgrp failed: Not a tty

@micahl
Copy link

micahl commented Oct 27, 2022

This is the official, permanent fix. It works for all versions except for Ubuntu Preview (Ubuntu 22.10), which will be fixed soon.

This is the fix:

sudo apt-get -y update
sudo apt-get -y upgrade snapd

@EduardGomezEscandell I did the above and then removed/reinstalled the snaps (b/c snap list reported them as broken) and then tried to build something and I'm getting this:

$ snapcraft --use-lxd
Launching a container.
Waiting for container to be ready
Waiting for network to be ready...
Interacting with snapd is not yet supported on Windows Subsystem for Linux 1.
This command has been left available for documentation purposes only.
An error occurred when trying to execute 'snap set system experimental.snapd-snap=true' with 'LXD': returned exit code 1.

@EduardGomezEscandell
Copy link
Collaborator

EduardGomezEscandell commented Oct 28, 2022

Thanks for the report, @micahl

This seems to be a separate issue. Snapd detects it is running on WSL but fails to detect it is WSL2, so it falls back to assuming it is WSL1. See here:
https://github.com/snapcore/snapd/blob/3c05e535e5cff4b64e4427e38494795fbbfd5122/release/release.go#L131

I opened a bug report here https://bugs.launchpad.net/snapd/+bug/1995083.

@isonlaxman
Copy link

isonlaxman commented Nov 21, 2022

Hi, I'm still facing issues with it even after the upgrade. I did try some of the workaround fixes for it before I saw the new release, not sure if that's the reason this is happening. I did try purge method mentioned at the top of this thread too.

Result of snap version
image

Result of snap refresh:
image

Also want to note: I'm connected to my company's VPN. I've tried this with it being on and off, and both give the same error.

@EduardGomezEscandell
Copy link
Collaborator

@isonlaxman

This error is different and probably not related to snap. Are you sure your systemd is enabled properly? Use systemctl is-system-running and ensure it returns online or degraded.

@edmondium
Copy link

@isonlaxman

This error is different and probably not related to snap. Are you sure your systemd is enabled properly? Use systemctl is-system-running and ensure it returns online or degraded.

What should I do if the message returns "degraded"?

@EduardGomezEscandell
Copy link
Collaborator

Then you're good, that's normal and snap should work. If you want to see exactly which services fail you can use systemctl --failed.

It happens because of some incompatibilities between these services and WSL that we have not yet addressed. Do you have the same issue as the one reported in the previous screenshot, or is it something else?

@kgkoutis
Copy link

kgkoutis commented Nov 22, 2022

@EduardGomezEscandell, I also have the same issue as the @isonlaxman in regards to snap version but snap refresh seems to work. systemctl is-system-running shows degraded and systemctl --failed shows systemd-sysusers.service failing

@EduardGomezEscandell
Copy link
Collaborator

What version of Ubuntu are you running? lsb_release -a

@kgkoutis
Copy link

@EduardGomezEscandell Ubuntu 22.04.1 LTS

@EduardGomezEscandell
Copy link
Collaborator

EduardGomezEscandell commented Nov 23, 2022

@kgkoutis If the error message is the same as @isonlaxman, then please file a new issue (under this same repo) because it seems to have a diferent origin as the original report. You can tag me there if you want.

In that issue please provide your $HOME\.wslconfig (in Windows) and /etc/wsl.conf if they exist. It could be some network thing but let's discuss it elsewhere, this thread is long and disjointed enough as it is right now.

@EduardGomezEscandell
Copy link
Collaborator

Closing because this issue only affects Kinetic, which is no longer supported on WSL (This or next week Ubuntu-Preview will start shipping with Lunar Lobster 🦞 )

@Dragon1573
Copy link

snapd with version 2.57.5 is currently available on Ubuntu 22.10 with source kinetic-updates, while kinetic source is still at 2.57.4+22.10ubuntu1.

Console Outputs
π lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.10
Release:        22.10
Codename:       kinetic

π apt list snapd -a
正在列表... 完成
snapd/kinetic-updates,now 2.57.5+22.10 amd64 [已安装]
snapd/kinetic 2.57.4+22.10ubuntu1 amd64

π snap --version
snap                         2.57.6
snapd                        不可用
series                       16
Windows Subsystem for Linux  -
kernel                       5.15.74.2-microsoft-standard-WSL2 (amd64)

π snap list
名称      版本             修订版本   追踪             发布者         注记
core20  20221027       1695   latest/stable  canonical✓  base
lxd     4.0.9-eb5e237  23991  4.0/stable/…   canonical✓  -
snapd   2.57.6         17883  latest/stable  canonical✓  snapd

It's also available to install and run Snap Packages with snap and snapd! (Some logs are folded)

Install & Run & Remove logs
π sudo snap install hello-world
确保 "hello-world" 的先决条件可用
......
确保 "core" 的先决条件可用
下载 snap "core" (14399),来自频道 "stable"
......
获取并检查 snap "core" (14399) 的断言
挂载 snap "core" (14399)
......
复制 snap "core" 的数据
设置 snap "core" (14399) 的安全配置
使 snap "core" (14399) 可用于系统
自动连接 snap "core" 的符合条件的插头和插槽
如果存在,则运行 "core" snap 的配置挂钩
下载 snap "hello-world" (29),来自频道 "stable"
......
获取并检查 snap "hello-world" (29) 的断言
挂载 snap "hello-world" (29)
......
设置 snap "hello-world" (29) 的安全配置
使 snap "hello-world" (29) 可用于系统
自动连接 snap "hello-world" 的符合条件的插头和插槽
设置 snap "hello-world" 的自动别名
设置 snap "hello-world" 的别名
运行 "hello-world" snap 的安装挂钩
启动 snap "hello-world" (29) 服务
如果存在,则运行 "hello-world" snap 的配置挂钩
hello-world 6.4 已从 Canonical✓ 安装

π hello-world
Hello World!

π sudo snap remove hello-world
停止 snap "hello-world" 服务
如果存在,则移除 "hello-world" snap 的挂钩
使 snap "hello-world" 不可用于系统
从 snap "hello-world" 中删除数据 (29)
已删除 hello-world

@EduardGomezEscandell
Copy link
Collaborator

EduardGomezEscandell commented Dec 5, 2022

Closing because this issue only affects Kinetic, which is no longer supported on WSL (This or next week Ubuntu-Preview will start shipping with Lunar Lobster 🦞 )

Kinetic is no longer affected, so this issue is now 100% solved. This is the fix:

sudo apt-get -y update
sudo apt-get -y upgrade snapd

Any problem you may have with snapd on WSL should be reported in a new issue.

@nndylsrknt
Copy link

@isonlaxman
This error is different and probably not related to snap. Are you sure your systemd is enabled properly? Use systemctl is-system-running and ensure it returns online or degraded.

What should I do if the message returns "degraded"?

what if it showing offline?

@nndylsrknt
Copy link

@isonlaxman

This error is different and probably not related to snap. Are you sure your systemd is enabled properly? Use systemctl is-system-running and ensure it returns online or degraded.

what if it is showing offline?

@Rayamenah
Copy link

@isonlaxman

This error is different and probably not related to snap. Are you sure your systemd is enabled properly? Use systemctl is-system-running and ensure it returns online or degraded.

what if it is showing offline?

Same here, what if it shows offline is there a fix for that

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

No branches or pull requests