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

Bug of WSL Preview - Empty /mnt/wslg/.X11-unix & /tmp/.X11-unix Directory #782

Closed
yqs112358 opened this issue Jul 7, 2022 · 15 comments
Closed
Labels
bug Something isn't working

Comments

@yqs112358
Copy link

yqs112358 commented Jul 7, 2022

Environment

Windows build number: Microsoft Windows [Version 10.0.22000.778]
Distribution version: Ubuntu 20.04
WSL version: 0.61.8.0
WSL kernel version: 5.10.102.1
WSLg version: 1.0.39

Steps to reproduce

  1. Install WSL Preview in Microsoft Store to upgrade WSL to the newest
  2. Open Ubuntu, try xterm but get xterm: Xt error: Can't open display: :0
  3. Check solutions in wiki Diagnosing "cannot open display" type issues with WSLg, then find that there is nothing in /tmp/.X11-unix and /mnt/wslg/.X11-unix. X11 socket was not created and linked correctly

image

image

  1. "Display" environment variable is correct:

image

WSL logs

versions.txt

WSLg ( x86_64 ): 1.0.39+Branch.main.Sha.cdbed82a21d382b5c74367c48a32ef4736cc8735
Mariner: VERSION="2.0.20220426"
mesa:
mesa:
pulseaudio: 2f0f0b8c3872780f15e275fc12899f4564f01bd5
FreeRDP: c574044a10003e50453acb4cf42801c5833fb572
weston: 4e99bb16dd44fc6daf4a45c46ba3e053c0637afa

weston.log

weston.log

pulseaudio.log

pulseaudio.log

Expected behavior

Everything works well, and GUI applications run normally.

Actual behavior

X11 socket was not created and linked correctly

@yqs112358 yqs112358 added the bug Something isn't working label Jul 7, 2022
@yqs112358
Copy link
Author

yqs112358 commented Jul 7, 2022

More:
I installed synaptic package manager and it works well after I fix environment variable manually:

export DISPLAY=:0
export WAYLAND_DISPLAY=wayland-0
export XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
export PULSE_SERVER=/mnt/wslg/PulseServer

I can start synaptic in terminal, so I think that the wayland backend has no problem because synaptic need it to launch.

But X11 programs (like xeyes, xterm,...) still cannot work. Maybe the part of X11 proxy had some problem during my install process.

@yqs112358
Copy link
Author

yqs112358 commented Jul 7, 2022

image

the wayland-0 socket is OK.

@yqs112358
Copy link
Author

yqs112358 commented Jul 14, 2022

After uninstall WSL Preview in Microsoft Store and restart WSL, X0 socket appears again in /mnt/wslg/.X11-unix.
It seems that the problem is solved so I close this issue. But I think there maybe some problems in WSL Preview, anyway.

@win98se
Copy link

win98se commented Jul 17, 2022

IMO, this issue needs to be kept open. It is a bug in WSL Preview, and it is not the solution for users to uninstall WSL Preview and use the stock WSL instead.

Additional information: I can't even remove the /tmp/.X11-unix directory as the error message says "Device or resource busy" -
image

@yqs112358
Copy link
Author

IMO, this issue needs to be kept open. It is a bug in WSL Preview, and it is not the solution for users to uninstall WSL Preview and use the stock WSL instead.

Additional information: I can't even remove the /tmp/.X11-unix directory as the error message says "Device or resource busy" - image

Oh I had the same problem, actually.

@yqs112358 yqs112358 reopened this Jul 17, 2022
@yqs112358 yqs112358 changed the title Empty /mnt/wslg/.X11-unix & /tmp/.X11-unix Directory [Bug of WSL Preview] Empty /mnt/wslg/.X11-unix & /tmp/.X11-unix Directory Jul 17, 2022
@yqs112358 yqs112358 changed the title [Bug of WSL Preview] Empty /mnt/wslg/.X11-unix & /tmp/.X11-unix Directory Bug of WSL Preview - Empty /mnt/wslg/.X11-unix & /tmp/.X11-unix Directory Jul 17, 2022
@alparslanozturk
Copy link

alparslanozturk commented Jul 27, 2022

I changed with these commands:

 sudo umount /tmp/.X11-unix
 sudo rm -rf /tmp/.X11-unix
 sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

@lisander-lopez
Copy link

I changed with these commands:

 sudo umount /tmp/.X11-unix
 sudo rm -rf /tmp/.X11-unix
 sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

Did not work for me, still got Error: Can't open display: :0 after a xcalc

@pfeerick
Copy link

I have the same issue, but for me, this only started in the last few weeks.

@ShaneCarr
Copy link

I changed with these commands:

 sudo umount /tmp/.X11-unix
 sudo rm -rf /tmp/.X11-unix
 sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

This does work. Lordie, i have a lot of trouble with wslg. maybe wsl can just do this on every start. yes i know but i mean it' s just really annoying. Even a hack would be appreciated.

@hakanserce
Copy link

Having the exact same issue. Started noticing after the 1.0.0.0 update.

@hakanserce
Copy link

The following (thanks to @alparslanozturk), followed by a wsl --shutdown worked for me:

 sudo umount /tmp/.X11-unix
 sudo rm -rf /tmp/.X11-unix
 sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

@edmondium
Copy link

To make it work, create /etc/tmpfiles.d/wslg.conf file with the following content:

#  This file is part of the debianisation of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# Type Path           Mode UID  GID  Age Argument
L+     /tmp/.X11-unix -    -    -    -   /mnt/wslg/.X11-unix

then restart WSL.

@Andrew-J-Larson
Copy link

I changed with these commands:

 sudo umount /tmp/.X11-unix
 sudo rm -rf /tmp/.X11-unix
 sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

Thanks! I had to remove the WSLg preview from my computer first, shutdown WSL, and then run these commands in my distro, and it got GUI working again.

To make it work, create /etc/tmpfiles.d/wslg.conf file with the following content:

#  This file is part of the debianisation of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# Type Path           Mode UID  GID  Age Argument
L+     /tmp/.X11-unix -    -    -    -   /mnt/wslg/.X11-unix

then restart WSL.

And this fixes the issue for subsequent restarts of WSL.

@brookman1
Copy link

Like the ln advice part but my /mnt/wslg/.X11-unix/ is empty. How do I add a Domain Socket in there? Do I have to umount the /mnt/wslg/.X11-unix/ itself? The question is of getting the X0 file in the target for the ln command.

@brookman1
Copy link

brookman1 commented Dec 26, 2024

Andrew-J-Larson summary, above, likely works. Follow his directions - my X11 works now on WSL2 Windows 11!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants