DamionGans / ubuntu-wsl2-systemd-script

[Does not work anymore!] Script to enable systemd support on current Ubuntu WSL2 images
1.56k stars 382 forks source link

wslg is broken with script #68

Open mirogl opened 2 years ago

mirogl commented 2 years ago

Hi, I had the same problem like described in https://github.com/microsoft/wslg/issues/238

xclock Error: Can't open display: :0

and the only solution for me was https://github.com/microsoft/wslg/issues/238#issuecomment-847804992

export DISPLAY=:0 sudo rm -rf /tmp/.X11-unix ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

Then it works. Is this really related to your script ?

thanks for your feedback.

Miro

aki-k commented 2 years ago

There's a systemd service called systemd-tmpfiles-setup.service that removes the /tmp/.X11-unix link to /mnt/wslg/.X11-unix.

ningacoding commented 2 years ago

Is totally related with this script, i created a clean ubuntu install with WSL, then tested xclock (x11-apps) to test GUI Apps until this everything OK. After install this script for snapd availability, the GUI apps throws the Error: Can't open display: :0

mirogl commented 2 years ago

Is totally related with this script, i created a clean ubuntu install with WSL, then tested xclock (x11-apps) to test GUI Apps until this everything OK. After install this script for snapd availability, the GUI apps throws the Error: Can't open display: :0

Hi, like written by aki-k this is a cleanupscript by systemd - so you can modify them or try the following, which works for me:

can you please try to add the following line at the end of your $HOME/.profile ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

than shutdown wsl with wsl.exe --shutdown

Does it work after starting WSL again ?

Thanks Miro

xulei890817 commented 2 years ago

Is totally related with this script, i created a clean ubuntu install with WSL, then tested xclock (x11-apps) to test GUI Apps until this everything OK. After install this script for snapd availability, the GUI apps throws the Error: Can't open display: :0

Hi, like written by aki-k this is a cleanupscript by systemd - so you can modify them or try the following, which works for me:

can you please try to add the following line at the end of your $HOME/.profile ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

than shutdown wsl with wsl.exe --shutdown

Does it work after starting WSL again ?

Thanks Miro

OK,works

ghost commented 2 years ago

Is totally related with this script, i created a clean ubuntu install with WSL, then tested xclock (x11-apps) to test GUI Apps until this everything OK. After install this script for snapd availability, the GUI apps throws the Error: Can't open display: :0

Hi, like written by aki-k this is a cleanupscript by systemd - so you can modify them or try the following, which works for me:

can you please try to add the following line at the end of your $HOME/.profile ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

than shutdown wsl with wsl.exe --shutdown

Does it work after starting WSL again ?

Thanks Miro

Is this possible without x11?

amarkovytch commented 2 years ago

Is totally related with this script, i created a clean ubuntu install with WSL, then tested xclock (x11-apps) to test GUI Apps until this everything OK. After install this script for snapd availability, the GUI apps throws the Error: Can't open display: :0

Hi, like written by aki-k this is a cleanupscript by systemd - so you can modify them or try the following, which works for me:

can you please try to add the following line at the end of your $HOME/.profile ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

than shutdown wsl with wsl.exe --shutdown

Does it work after starting WSL again ?

Thanks Miro

You also need to comment out this line in /usr/lib/tmpfiles.d/x11.conf :

D! /tmp/.X11-unix 1777 root root 10d

Otherwise the wrong link will be recreated upon restart with root permissions and you won't be able to create your link