wslg
wslg copied to clipboard
Bug of WSL Preview - Empty /mnt/wslg/.X11-unix & /tmp/.X11-unix Directory
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
-
Install
WSL Preview
in Microsoft Store to upgrade WSL to the newest -
Open Ubuntu, try
xterm
but getxterm: Xt error: Can't open display: :0
-
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 -
"Display" environment variable is correct:
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
pulseaudio.log
Expected behavior
Everything works well, and GUI applications run normally.
Actual behavior
X11 socket was not created and linked correctly
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.

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.
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" -
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" -
Oh I had the same problem, actually.
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
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
I have the same issue, but for me, this only started in the last few weeks.
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.
Having the exact same issue. Started noticing after the 1.0.0.0 update.
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
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.
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.
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.