nullpo-head / wsl-distrod

Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability.
MIT License
1.9k stars 90 forks source link

Bind mount `/tmp/.X11-unix` for newer version of WSL2 #57

Closed Locietta closed 2 years ago

Locietta commented 2 years ago

Fix #56.

After WSL 0.60.0 release, microsoft switched to bind mount the /tmp/.X11-unix rather than symlink it as they previously do. This breaks wslg in Distrod for latest WSL on MS Store.

Distrod should bind mount for WSL 0.60.0, and keep the symlink strategy for older versions of WSL.

I've tested the fix on WSL 0.60.0, WSL 0.58.3 and in-box WSL, all of them worked ok.

EDIT: Before this PR is merged, you may use opt tar packaged by me for a while 👉 opt_distrod.tar.gz

herrwinfried commented 2 years ago

are you sure you fixed it? it didn't work for me

Locietta commented 2 years ago

Hi, @herrwinfried, I'm now using it for myself (WSL0.60.0 and archwsl) and doesn't see any issue🤔

Could you please test opt_distrod.tar.gz to see if it works? If it also fails, please paste the output of ls /run/systemd/system/systemd-tmpfiles-setup.service.d and ls /tmp/.X11-unix to see what's going wrong...

herrwinfried commented 2 years ago

Hi, @herrwinfried, I'm now using it for myself (WSL0.60.0 and archwsl) and doesn't see any issue🤔

Could you please test opt_distrod.tar.gz to see if it works? If it also fails, please paste the output of ls /run/systemd/system/systemd-tmpfiles-setup.service.d and ls /tmp/.X11-unix to see what's going wrong...

yes this works on the openSUSE TW windows store download you mentioned, thanks. image

Locietta commented 2 years ago

I just noticed a bug: when systemd-tmpfiles --create is executed, /tmp/.X11-unix will be cleaned up.

I've fixed it and updated the opt tar pinned at the beginning.

leoleoasd commented 2 years ago

I tried the tarball and it gives the following error everytime i open wsl:

C:\Users\Leo>wsl
-zsh: symbol lookup error: /opt/distrod/lib/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE

Maybe it's something with your compile environment?

leoleoasd commented 2 years ago

I'm using latest archlinux.

herrwinfried commented 2 years ago

I downloaded the latest edited and it works for me. Could it be a missing step for arch linux. @leoleoasd image

Locietta commented 2 years ago

I tried the tarball and it gives the following error everytime i open wsl:

C:\Users\Leo>wsl
-zsh: symbol lookup error: /opt/distrod/lib/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE

Maybe it's something with your compile environment?

It looks like you directly extract the tarball to /opt, which might cause the trouble. You are mixing the libs from repo owner (probably package his tarball on ubuntu) and me (on Arch).

Remove the original /opt/distrod and re-install the tarball should fix this. @leoleoasd

And in case you can't open wsl shell, use wsl -u root -e /opt/distrod/bin/distrod disable to disable distrod from outside.

leoleoasd commented 2 years ago

That worked for me. Thanks!

Locietta commented 2 years ago

Seems like CI fails because no /mnt/wslg/.X11-unix on test runner for bind mount... while we don't have permission to create it on github runner😥 (see https://github.com/Locietta/wsl-distrod/runs/7183455218?check_suite_focus=true).

It looks ok when I ran tests on my WSL2 though. Having no idea about how to solve the test failure.

EDIT: Maybe we shouldn't do any bind mount if /mnt/wslg/.X11-unix doesn't exist? It seems reasonable for some older wsl without wslg support, and it helps to fix the test failure.

Locietta commented 2 years ago

EDIT: Or maybe we shouldn't do any bind mount if /mnt/wslg/.X11-unix doesn't exist? It seems reasonable for some older wsl without wslg support, and it helps to fix the test failure.

Applied this fix, and it now can pass ci.

nullpo-head commented 2 years ago

Hi @Locietta ! I truly appreciate your contribution! And I'm sorry for my late response. 🙇‍♂️ Overall it looks good to me, but let me check it around tomorrow. I may ask you for some refactoring, or I could do it by myself after merging your contribution. Thanks so much again!

dyharlan commented 2 years ago

I tried installing the latest release, and it doesn't seem to fix the issue?

Locietta commented 2 years ago

@dyharlan v0.1.7 looks good to me, could you check ls /run/systemd/system/systemd-tmpfiles-setup.service.d and ls /tmp/.X11-unix?

leoleoasd commented 2 years ago

v0.1.7 gives me

<3>init: (12) ERROR: CreateProcessEntryCommon:528: execvpe /opt/distrod/alias/usr/bin/zsh failed 2
<3>init: (12) ERROR: CreateProcessEntryCommon:538: Create process not expected to return

Is there something with my installation? I just delete all files inside opt/distrod and replace it with opt_distrod.tar.gz

leoleoasd commented 2 years ago

v0.1.7 gives me

<3>init: (12) ERROR: CreateProcessEntryCommon:528: execvpe /opt/distrod/alias/usr/bin/zsh failed 2
<3>init: (12) ERROR: CreateProcessEntryCommon:538: Create process not expected to return

Is there something with my installation? I just delete all files inside opt/distrod and replace it with opt_distrod.tar.gz

disabling and re-enabling it after replacing the file fixes this issue.

gifnksm commented 2 years ago

In my environment, /run/tmpfiles.d/x11.conf was still mounted after upgrading Distrod to v0.17 (even after disabling and enabling Distrod). I removed everything under /opt/distrod and reinstalled Distrod again, and the problem no longer occurs.