wslg icon indicating copy to clipboard operation
wslg copied to clipboard

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

Open yqs112358 opened this issue 2 years ago • 13 comments

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

  4. "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 avatar Jul 07 '22 04:07 yqs112358

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 avatar Jul 07 '22 06:07 yqs112358

image the wayland-0 socket is OK.

yqs112358 avatar Jul 07 '22 15:07 yqs112358

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.

yqs112358 avatar Jul 14 '22 11:07 yqs112358

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

win98se avatar Jul 17 '22 02:07 win98se

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 avatar Jul 17 '22 02:07 yqs112358

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

alparslanozturk avatar Jul 27 '22 09:07 alparslanozturk

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

lisander-lopez avatar Oct 10 '22 01:10 lisander-lopez

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

pfeerick avatar Nov 10 '22 09:11 pfeerick

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.

ShaneCarr avatar Nov 11 '22 19:11 ShaneCarr

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

hakanserce avatar Dec 04 '22 23:12 hakanserce

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

hakanserce avatar Dec 04 '22 23:12 hakanserce

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.

edmondium avatar Feb 22 '24 14:02 edmondium

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.

Andrew-J-Larson avatar Aug 02 '24 19:08 Andrew-J-Larson

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 avatar Oct 08 '24 20:10 brookman1