microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
9.95k stars 301 forks source link

No output from `ls /tmp/.X11-unix` when multiple Linux distro are installed #844

Open zzehli opened 1 year ago

zzehli commented 1 year ago

Windows build number:

Microsoft Windows [Version 10.0.22000.978]

Your Distribution version:

Ubuntu 18.04

Your WSL versions:

WSL version: 0.66.2.0 Kernel version: 5.15.57.1 WSLg version: 1.0.42 MSRDC version: 1.2.3401 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22000.978

Steps to reproduce:

Unable to open GUI softwares.

$ xcalc
Error: Can't open display: :0

Tried to solve the problem by following the steps outlined here, but no success.

WSL logs:

weston.log stderr.log pulseaudio.log

WSL dumps:

No response

Expected behavior:

The ls /tmp/.X11-unix should output X0

Actual behavior:

It output nothing.

$ echo $DISPLAY
:0
$ ls -la /tmp/.X11-unix
total 4
drwxrwxrwx 2 root root   60 Sep 26 17:14 .
drwxrwxrwt 3 root root 4096 Sep 26 17:17 ..
lrwxrwxrwx 1 jae  jae    19 Sep 26 17:14 .X11-unix -> /mnt/wslg/.X11-unix
$ ls /tmp/.X11-unix
$
c4artisan commented 1 year ago

looks like i have the same problem.........

zzehli commented 1 year ago

I have both Ubuntu 20 and 18 installed on my wsl2. Ubuntu 20 has no problem opening GUI apps, only 18 has problem. For now I am using VcXsrv to open GUIs on Ubuntu 18.

oleksis commented 1 year ago

I wrote about this issue, having the same behaviour: X server display socket is being deleted

oleksis commented 1 year ago

✅ Update the sequence of steps and resolve this issue: Init /tmp/.X11-unix is overwritten by mounts

hideyukn88 commented 1 year ago

Please update to WSL 0.70.0 by wsl --update, and check if this still occurs, we have addressed several X connection issues in this release, thanks!

oleksis commented 1 year ago

I have updated and the issue continues

➜ wsl --version
WSL version: 0.70.0.0
Kernel version: 5.15.68.1
WSLg version: 1.0.45
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.25211.1001
➜ ls -la /tmp/.X11-unix/
total 24
drwxrwxrwt  2 root root    40 Oct 13 04:49 .
drwxrwxrwt 14 root root 20480 Oct 13 04:49 ..

PD: Make this test removing sudo mv /etc/tmpfiles.d/wslg.conf ~ from the previous solution with WSL version 0.68.2.0

hideyukn88 commented 1 year ago

@oleksis, thanks for trying out, WSL 0.70.0 contains the fix for the issue like @zzehli mentioned at https://github.com/microsoft/wslg/issues/844#issuecomment-1260271455 where multiple distros are installed, and one distro is working but other is not. But there is still some having missing X11-Unix socket issue after update to 0.70.0 like https://github.com/microsoft/wslg/issues/853, I will continue to look into such issue, thanks!

oleksis commented 1 year ago

Just update to wsl v1.0.0 from the web options and after few minutes the problem repeat. This time i fix like before. All the steps for Update to WSL v1.0.0

hideyukn88 commented 1 year ago

@oleksis, do you have systemd enabled? thanks!

imaginabit commented 1 year ago

I have the same problem with systemd enabled, All worked until update wsl, I have systemd enabled

PS C:\Users\fernando.ramirez> wsl --version Versión de WSL: 1.0.0.0 Versión de kernel: 5.15.74.2 Versión de WSLg: 1.0.47 Versión de MSRDC: 1.2.3575 Versión de Direct3D: 1.606.4 Versión DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Versión de Windows: 10.0.22621.819

:~$ ls -la /tmp/.X11-unix/ total 52 drwxrwxrwt 2 root root 40 Nov 17 03:06 . drwxrwxrwt 14 root root 49152 Nov 17 03:09 ..

:~$ ls -la /wslg/.X11-unix/ total 0 drwxrwxrwt 2 root root 40 Nov 17 03:06 . drwxrwxrwt 7 root root 300 Nov 17 03:06 ..

I try editing /etc/tmpfiles.d/wslg.conf with

#  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 -    -    -    -   /wslg/.X11-unix

change /mnt/wslg for /wslg , in my system /mnt/wslg exist but is empty ,

didn't solve it

oleksis commented 1 year ago

@oleksis, do you have systemd enabled? thanks!

Systemd is enable by default. I thinks I have enabled. How verify?

imaginabit commented 1 year ago

Systemd is enable by default. I thinks I have enabled. How verify?

you have to enable it on /etc/wsl.conf

cat /etc/wsl.conf
[boot]
systemd=true
# Automatically mount Windows drive when the distribution is launched
[automount]
# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
enabled = true
# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c.
root = /
imaginabit commented 1 year ago

Ok now works for me

( see ajkelsey comment https://github.com/microsoft/wslg/issues/880#issuecomment-1319169708 ) and now : xeyes -> works firefox ( from snap ) ->Error: cannot open display: :0 firefox ( from Appimage file ) -> works

hideyukn88 commented 1 year ago

@imaginabit, would you please check if gdm.service is running on your system by systemctl -t service | grep gdm ? thanks!

oleksis commented 1 year ago

Here my WSL2 configuration

➜ cat /etc/wsl.conf
[boot]
systemd=true

➜ systemctl -t service | grep gdm
  gdm.service                          loaded active running GNOME Display Manager
oleksis commented 1 year ago

With the gdm service active and the last steps, all keep working. Using Docker 4.14.1 and WSL2

➜ wsl.exe --version
WSL version: 1.0.0.0
Kernel version: 5.15.74.2
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.25236.1010

➜ ls -la /tmp/.X11-unix/
total 0
drwxrwxrwx 2 root    root     60 Nov 19 21:25 .
drwxrwxrwt 7 root    root    300 Nov 19 21:25 ..
srwxrwxrwx 1 oleksis oleksis   0 Nov 19 21:25 X0

➜ systemctl -t service | grep gdm
  gdm.service                          loaded active running GNOME Display Manager
oleksis commented 1 year ago

Testing in Windows 10 22H2 (OS Build 19045.2311)

C:\>ver

Microsoft Windows [Version 10.0.19045.2311]

C:\>wsl --version
Versión de WSL: 1.0.1.0
Versión de kernel: 5.15.74.2
Versión de WSLg: 1.0.47
Versión de MSRDC: 1.2.3575
Versión de Direct3D: 1.606.4
Versión DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Versión de Windows: 10.0.19045.2311

C:\>wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu                 Running         2
  docker-desktop-data    Stopped         2
  docker-desktop         Stopped         2

Default distro Ububtu

➜ ll /tmp/.X11-unix/
total 4
drwxrwxrwx  2 root    root      60 Nov 22 19:30 ./
drwxrwxrwt 15 root    root    4096 Nov 22 20:55 ../
srwxrwxrwx  1 oleksis oleksis    0 Nov 22 19:30 X0=

➜ cat /etc/wsl.conf
[boot]
systemd=true

➜ systemctl -t service | grep gdm
  gdm.service                          loaded active     running       GNOME Display Manager

Note the socket name add the equal sign in the name X0=

Masamune3210 commented 1 year ago

did you mean to do ll instead of ls?

AlphaScorpii-dev commented 1 year ago

I have 3 distributions installed right now (Debian / Ubuntu / openSUSE Tumbleweed). Both Debian and Ubuntu are working, the openSUSE is the one that breaks after an initial update (works after a fresh install, not after a zypper dup) For some reason, /tmp won't be populated with the entries listed in usr/lib/tmpfiles.d/x11.conf

imaginabit commented 1 year ago

@imaginabit, would you please check if gdm.service is running on your system by systemctl -t service | grep gdm ? thanks!

 systemctl -t service | grep gdm
 gdm.service                                            loaded active running GNOME Display Manager

when I stop the service with systemctl stop gdm.service and try to execute firefox ,get again

Error: cannot open display: :0

sudo systemctl disable gdm.service 

and

wsl --shutdown

and again get display error but also

:~$ firefox
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/tmp/.X11-unix /tmp/.X11-unix none bind,ro 0 0): cannot use "/var/lib/snapd/hostfs/tmp/.X11-unix" as bind-mount source: not a directory
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/gimp/2.0/help /usr/share/gimp/2.0/help none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/gimp/2.0/help" because it would affect the host in "/var/lib/snapd"
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/xubuntu-docs /usr/share/xubuntu-docs none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/xubuntu-docs" because it would affect the host in "/var/lib/snapd"
Error: cannot open display: :0

remove firefox and install it again with

snap remove firefox

# in other terminal 
snap install firefox

and now I get the same Error: cannot open display: :0 again without the other messages