47

Running Snaps on WSL2 (Insiders only for now)

 2 years ago
source link: https://forum.snapcraft.io/t/running-snaps-on-wsl2-insiders-only-for-now/13033/21
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Running Snaps on WSL2 (Insiders only for now)

Also, when I got snapd to work under WSL 2, I had apparmor in the kernel, but I’m still only getting partial confinement. Anyone out there who can suggest what might need tweaking to get to strict?

Relevant output:

❯ snap debug confinement
partial

❯ snap debug sandbox-features
apparmor:             kernel:caps kernel:domain kernel:file kernel:mount kernel:namespaces kernel:network_v8 kernel:policy kernel:ptrace kernel:query kernel:rlimit kernel:signal parser:unsafe policy:downgraded support-level:partial
confinement-options:  classic devmode
dbus:                 mediated-bus-access
kmod:                 mediated-modprobe
mount:                freezer-cgroup-v1 layouts mount-namespace per-snap-persistency per-snap-profiles per-snap-updates per-snap-user-profiles stale-base-invalidation
seccomp:              bpf-actlog bpf-argument-filtering kernel:allow kernel:errno kernel:kill_process kernel:kill_thread kernel:log kernel:trace kernel:trap
udev:                 device-cgroup-v1 tagging
25 days later

Hi there,

Thanks for all your work on this!!! But, I think I’ve borked something along the way. I followed the instructions successfully. I did not do the “optional” part. Snap is working now (thank you sir!):

snap    2.40+18.04
snapd   2.40+18.04
series  16
ubuntu  18.04
kernel  4.19.67-microsoft-standard

Then I tried to build my Docker image. Shortly after it gave up and provided this error message:

failed to build: cgroups: cannot find cgroup mount destination: unknown

I restarted. When I try to open a WSL project in VSCode I get the following dialog box:

“VS Code Server for WSL failed to start. No messages received for 90s Check WSL terminal for more details”

The terminal says:

[2019-10-18 19:50:23.859] Starting VS Code Server inside WSL (ubuntu)
[2019-10-18 19:50:23.860] Extension version: 0.39.9, Windows build: 18980. Multi distro support: enabled. WSL path support: enabled
[2019-10-18 19:50:23.968] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d ubuntu -e sh -c “[ -d ~/.vscode-server-insiders/bin/5aec74ad3b55bb9463e717ec950e665288accd0f ] && echo found || ([ -f /etc/alpine-release ] && echo alpine || echo x64)”
[2019-10-18 19:50:24.045] Server install found in WSL
[2019-10-18 19:50:24.045] Launching C:\WINDOWS\System32\wsl.exe -d ubuntu sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 5aec74ad3b55bb9463e717ec950e665288accd0f insider .vscode-server-insiders 0 ’ in c:\Users\Joel.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.39.9
[2019-10-18 19:50:24.267] your 131072x1 screen size is bogus. expect trouble

I am on Windows Build 18980.vb_release.190907-1301

Can you give me a few ideas on how to unbork it?

Thanks daniel. I went through all the steps again and recreated those two scripts as suggested. I’m sure those are there and correct now.

I did mess up one step the first time I went through the steps. I pasted the cmd.exe ... in the Ubuntu terminal instead of the Windows terminal. So I have fixed that.

I am getting a diff error message this time, which is probably a good thing:

During startup of VSCode, as it is Opening Remote, I am still getting the Starting VS Code in WSL (ubuntu): Installing WSL components message in the corner.

Followed by this error:

[2019-10-21 14:02:37.046] Starting VS Code Server inside WSL (ubuntu) [2019-10-21 14:02:37.047] Extension version: 0.39.9, Windows build: 18980. Multi distro support: enabled. WSL path support: enabled [2019-10-21 14:02:37.509] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d ubuntu -e sh -c "[ -d ~/.vscode-server-insiders/bin/82ca6ba87f450245f665ab7a5f3a686e2cd00045 ] && echo found || ([ -f /etc/alpine-release ] && echo alpine || echo x64)" [2019-10-21 14:02:37.885] No server install found in WSL, needs x64 [2019-10-21 14:02:37.887] Launching C:\WINDOWS\System32\wsl.exe -d ubuntu sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 82ca6ba87f450245f665ab7a5f3a686e2cd00045 insider .vscode-server-insiders 0 ' in c:\Users\Joel\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.39.9 [2019-10-21 14:02:38.222] your 131072x1 screen size is bogus. expect trouble [2019-10-21 14:04:10.895] VS Code Server for WSL failed to start. No messages received for 90s [2019-10-21 14:04:10.895] For help with startup problems, go to [2019-10-21 14:04:10.895] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips

The only diff between those messages is

Before:

[2019-10-18 19:50:24.045] Server install found in WSL

After:

[2019-10-21 14:02:37.885] No server install found in WSL, needs x64

And this at the end:

[2019-10-21 14:04:10.895] VS Code Server for WSL failed to start. No messages received for 90s [2019-10-21 14:04:10.895] For help with startup problems, go to [2019-10-21 14:04:10.895] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips

Do you have any other suggestions? Thank you for your time.

As a debugging step, can you open a terminal in your Ubuntu-based WSL. Separately, tell VSCode to connect so that you reproduce the timeout. Once you’ve hit the timeout run the following in the terminal you opened first:

$ grep WSLENV ~/.systemd-env

We’re looking for the output of grep to read similar to:

WSLENV=VSCODE_WSL_EXT_LOCATION/up:BASH_ENV/u

If it is there, run another grep:

$ grep VSCODE_WSL_EXT_LOCATION= ~/.systemd-env

This is expected to show something similar to below, with the path for your user folder instead of mine:

VSCODE_WSL_EXT_LOCATION=/mnt/c/Users/yabea/.vscode-insiders/extensions/ms-vscode-remote.remote-wsl-0.39.9

Thank you daniel

I screwed up by editing the visudo file in vim instead of visudo. After I fixed that, everything seems to be working. So, everything in the tutorial seems right on. Thank yoiu.

This tutorial is not about Docker so feel free to ignore this question, but when I try to open Docker in windows I get a message that says,

“This is a command line tool.
You need to open cmd.exe and run it from there.”

Edit: When I use a docker command like docker ps it says

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

After googling an hour I think it might be related to it looking for it in the old location, and we are sorta running in a different way.

Again, feel free to ignore this Docker question. It a little is off-topic. Thank you for your help.

Well… things are a little more borked that I thought. I can’t get the “WSL 2 Tech Preview” Docker 2.1.00 to run anymore. When I click the “start” button in the Tech Preview GUI It says

Error from Lifecycle Server
exit status 1

Here is the log from Docker Lifecycle:

Here is the log from Docker Daemon:

The PATH file does seem to have unescaped characters in it. It was not an issue before, and I don’t think they were introduced in these instructions.

Also worth noting. When I tried the troubleshooting greps, those enteries were all missing. I added them to the file manually. Not sure why they were missing or if other things were missing too. I tried to followed the instructions to a T.

Any help debugging would be helpful. I thought it would be helpful to add this comment for other people trying this.

I’ve been trying to debug it for a few hours. I had a co-worker who is much smarter than me try to help me fix this for an hour, and he gave up and suggested I nuke it all and remove any new files that were introduced. If I have lost the ability to use VSCode with WSL 2, its not worth the trade off. High stakes to get Snap.

This is all cutting edge experimental stuff with WSL 2. I’m sure its me and not the instructions. It is just part of being on the latest and greatest new stuff.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK