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

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

Merged
merged 4 commits into from Jul 7, 2022

Conversation

Locietta
Copy link
Contributor

@Locietta Locietta commented Jun 18, 2022

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
Copy link

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

@Locietta
Copy link
Contributor Author

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
Copy link

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

* bind-mount `/tmp/.X11-unix` for WSL after 0.60.0
* keep the symlink method for older WSL versions
* modify `/run` mounts to avoid systemd to clean up `/tmp/.X11-unix`
  * override systemd-tmpfiles-{setup, clean}.service to exclude `/tmp/.X11-unix`
  * don't mount `x11.conf` if WSL>= 0.60.0, this avoid `systemd-tmpfiles --create` touching `/tmp/.X11-unix`
@Locietta
Copy link
Contributor Author

Locietta commented Jun 25, 2022

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
Copy link

leoleoasd commented Jun 26, 2022

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
Copy link

I'm using latest archlinux.

@herrwinfried
Copy link

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

@Locietta
Copy link
Contributor Author

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
Copy link

That worked for me. Thanks!

@Locietta
Copy link
Contributor Author

Locietta commented Jul 4, 2022

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
Copy link
Contributor Author

Locietta commented Jul 4, 2022

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
Copy link
Owner

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!

Copy link
Owner

@nullpo-head nullpo-head left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me. Thanks so much! I've add a little requests for improvements. I'd appreciate it if you could update it if you can.

distrod/distrod/tests/integration_test.rs Outdated Show resolved Hide resolved
distrod/distrod/tests/integration_test.rs Outdated Show resolved Hide resolved
* test for `/run/systemd/system/systemd-tmpfiles-setup.service.d`
* remove symlink test
@Locietta Locietta requested a review from nullpo-head July 7, 2022 14:29
@nullpo-head nullpo-head merged commit 921bc3c into nullpo-head:main Jul 7, 2022
@dyharlan
Copy link

dyharlan commented Jul 8, 2022

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

@Locietta
Copy link
Contributor Author

Locietta commented Jul 8, 2022

@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
Copy link

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
Copy link

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
Copy link

gifnksm commented Jul 8, 2022

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.

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

Successfully merging this pull request may close these issues.

[Bug]: Distrod causes X11 to not work under wslg.
6 participants