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

Unable to start X server in WSL2 #1172

Open
Cteljr opened this issue Jan 3, 2024 · 11 comments
Open

Unable to start X server in WSL2 #1172

Cteljr opened this issue Jan 3, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@Cteljr
Copy link

Cteljr commented Jan 3, 2024

Windows build number:

Microsoft Windows [Version 10.0.22000.2538]

Your Distribution version:

22.04

Your WSL versions:

WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.2538

Steps to reproduce:

Following the instructions at https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg

clester@WIN-GPNU4RS958T:~$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.59+Branch.main.Sha.2bffa4a1867601b1fd0e3c7bb59ada9f6131c28e
Mariner: VERSION="2.0.20230630"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: 1c19fc5ecdd4552f36f77256e1fb53225801aff0
clester@WIN-GPNU4RS958T:~$ ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix
ln: failed to create symbolic link '/tmp/.X11-unix/.X11-unix': Read-only file system
clester@WIN-GPNU4RS958T:~$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.59+Branch.main.Sha.2bffa4a1867601b1fd0e3c7bb59ada9f6131c28e
Mariner: VERSION="2.0.20230630"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: 1c19fc5ecdd4552f36f77256e1fb53225801aff0
clester@WIN-GPNU4RS958T:~$ echo $DISPLAY
:0
clester@WIN-GPNU4RS958T:~$ ls -la /tmp/.X11-unix
total 4
drwxrwxrwx 2 root root   40 Jan  2 19:58 .
drwxrwxrwt 7 root root 4096 Jan  2 20:08 ..
clester@WIN-GPNU4RS958T:~$ ls -la /tmp/.X11-unix/
total 4
drwxrwxrwx 2 root root   40 Jan  2 19:58 .
drwxrwxrwt 7 root root 4096 Jan  2 20:08 ..
clester@WIN-GPNU4RS958T:~$ ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix
ln: failed to create symbolic link '/tmp/.X11-unix/.X11-unix': Read-only file system
clester@WIN-GPNU4RS958T:~$ ls -la /tmp/.X11-unix/
total 4
drwxrwxrwx 2 root root   40 Jan  2 19:58 .
drwxrwxrwt 7 root root 4096 Jan  2 20:08 ..

WSL logs:

weston.log
pulseaudio.log
stderr.log
wlog.log

WSL dumps:

No response

Expected behavior:

Should be able to run Xserver; also, per the instructions at the github troubleshooting link (above), I should be able to create the link for the Xserver, i.e.
sudo rm -r /tmp/.X11-unix
ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix
Both commands should work.

Actual behavior:

The rm command fails with: rm: cannot remove '/tmp/.X11-unix': Device or resource busy, and
the ln command fails with ln: failed to create symbolic link '/tmp/.X11-unix/.X11-unix': Read-only file system,
although ls -la /tmp/.X11-unix shows

total 4
drwxrwxrwx 2 root root   40 Jan  2 19:58 .
drwxrwxrwt 7 root root 4096 Jan  2 20:08 ..

which doesnt appear to be a read-only filesysytem.
BTW sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix fares no better:
ln: failed to create symbolic link '/tmp/.X11-unix/.X11-unix': Read-only file system

@Cteljr Cteljr added the bug Something isn't working label Jan 3, 2024
@kiocosta
Copy link

kiocosta commented Jan 4, 2024

Having the same issue here.
Using Microsoft Windows [Version 10.0.19044.3803], ArchWSL and WSL2.
Already tried wsl --update

~ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.59+Branch.main.Sha.2bffa4a1867601b1fd0e3c7bb59ada9f6131c28e
Mariner: VERSION="2.0.20230630"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: 1c19fc5ecdd4552f36f77256e1fb53225801aff0

~  echo $DISPLAY
:0

~  ls -la /tmp/.X11-unix/
total: 0
drwxrwxrwx 2 root root  80 Jan  6 19:39 .
drwxrwxrwt 8 root root 320 Jan  6 19:34 ..
srwxrwxrwx 1 kio  kio    0 Jan  6 19:34 X0
lrwxrwxrwx 1 kio  kio   19 Jan  6 19:39 .X11-unix -> /mnt/wslg/.X11-unix

~  ls -la /tmp/.X11-unix
lrwxrwxrwx 1 kio kio 19 Jan  8 15:09 /tmp/.X11-unix -> /mnt/wslg/.X11-unix

~  uname -r
5.15.133.1-microsoft-standard-WSL2

/mnt/wslg/weston.log

In my case, I get this message when trying to open Cypress:

[1554:0104/175201.023492:ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY
[1554:0104/175201.023535:ERROR:env.cc(255)] The platform failed to initialize.  Exiting.

Other GUI applications are not openning but don't output any message.

EDIT:
In my case, the problem only occurs with ArchWSL. Installed Ubuntu and had no problems.
This is the X-related info that is in Ubuntu (which works fine):

 cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.59+Branch.main.Sha.2bffa4a1867601b1fd0e3c7bb59ada9f6131c28e
Mariner: VERSION="2.0.20230630"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: 1c19fc5ecdd4552f36f77256e1fb53225801aff0

~  echo $DISPLAY
:0

~ ls -la /tmp/.X11-unix/
total 4
drwxrwxrwx  2 root root   60 Jan  8 14:36 .
drwxrwxrwt 24 root root 4096 Jan  8 18:11 ..
srwxrwxrwx  1 kio  kio     0 Jan  8 14:36 X0

~ ls -la /tmp/.X11-unix
total 4
drwxrwxrwx  2 root root   60 Jan  8 14:36 .
drwxrwxrwt 24 root root 4096 Jan  8 18:11 ..
srwxrwxrwx  1 kio  kio     0 Jan  8 14:36 X0

~  uname -r
5.15.133.1-microsoft-standard-WSL2

@SimonCrouzet
Copy link

Same issue here!

Using Microsoft Windows [version 10.0.22631.2861] and WSL2

~$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.59+Branch.main.Sha.2bffa4a1867601b1fd0e3c7bb59ada9f6131c28e
Mariner: VERSION="2.0.20230630"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: 1c19fc5ecdd4552f36f77256e1fb53225801aff0

~$ echo $DISPLAY
172.21.32.1:0.0

~$ ls -la /tmp/.X11-unix
total 4
drwxrwxrwx  2 root  root    60 Jan  8 10:21 .
drwxrwxrwt 12 root  root  4096 Jan  8 10:21 ..
srwxrwxrwx  1 simon simon    0 Jan  8 10:21 X0

~$ ls -la /tmp/.X11-unix/
total 4
drwxrwxrwx  2 root  root    60 Jan  8 10:21 .
drwxrwxrwt 12 root  root  4096 Jan  8 10:26 ..
srwxrwxrwx  1 simon simon    0 Jan  8 10:21 X0

/mnt/wslg/weston.log

I used VcXsrv months (years?) ago and do not have it installed anymore, but seems like it's still messing up WSLg somehow

@kiocosta
Copy link

kiocosta commented Jan 8, 2024

Same issue here!

Using Microsoft Windows [version 10.0.22631.2861] and WSL2

~$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.59+Branch.main.Sha.2bffa4a1867601b1fd0e3c7bb59ada9f6131c28e
Mariner: VERSION="2.0.20230630"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: 1c19fc5ecdd4552f36f77256e1fb53225801aff0

~$ echo $DISPLAY
172.21.32.1:0.0

~$ ls -la /tmp/.X11-unix
total 4
drwxrwxrwx  2 root  root    60 Jan  8 10:21 .
drwxrwxrwt 12 root  root  4096 Jan  8 10:21 ..
srwxrwxrwx  1 simon simon    0 Jan  8 10:21 X0

~$ ls -la /tmp/.X11-unix/
total 4
drwxrwxrwx  2 root  root    60 Jan  8 10:21 .
drwxrwxrwt 12 root  root  4096 Jan  8 10:26 ..
srwxrwxrwx  1 simon simon    0 Jan  8 10:21 X0

/mnt/wslg/weston.log

I used VcXsrv months (years?) ago and do not have it installed anymore, but seems like it's still messing up WSLg somehow

what linux distro are you using?

@kiocosta
Copy link

kiocosta commented Jan 10, 2024

As suggested in this issue, the issue is solved by adding export LIBGL_ALWAYS_INDIRECT=1 to ~/.zshrc (or ~/.bashrc if you use bash) and then running source ~/.zshrc so the changes take effect.

@SimonCrouzet
Copy link

SimonCrouzet commented Jan 20, 2024

When trying the fix proposed above, I realized that I still had some remaining of my previous VcXsrv install in my .bashrc file:

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
export LIBGL_ALWAYS_INDIRECT=1
sudo /etc/init.d/dbus start &> /dev/null

I removed the first and third line, and everything is working well now

@Cteljr
Copy link
Author

Cteljr commented Jan 22, 2024

As suggested in this issue, the issue is solved by adding export LIBGL_ALWAYS_INDIRECT=1 to ~/.zshrc (or ~/.bashrc if you use bash) and then running source ~/.zshrc so the changes take effect.

Tried this too, though I wasn't using ArchWSL, but still X11 doesn't appear to be running and the link fix still fails as described in the original issue.

@kiocosta
Copy link

As suggested in this issue, the issue is solved by adding export LIBGL_ALWAYS_INDIRECT=1 to ~/.zshrc (or ~/.bashrc if you use bash) and then running source ~/.zshrc so the changes take effect.

Tried this too, though I wasn't using ArchWSL, but still X11 doesn't appear to be running and the link fix still fails as described in the original issue.

Which distro are you using?

@Cteljr
Copy link
Author

Cteljr commented Jan 23, 2024

As suggested in this issue, the issue is solved by adding export LIBGL_ALWAYS_INDIRECT=1 to ~/.zshrc (or ~/.bashrc if you use bash) and then running source ~/.zshrc so the changes take effect.

Tried this too, though I wasn't using ArchWSL, but still X11 doesn't appear to be running and the link fix still fails as described in the original issue.

Which distro are you using?

$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.59+Branch.main.Sha.2bffa4a1867601b1fd0e3c7bb59ada9f6131c28e
Mariner: VERSION="2.0.20230630"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: 1c19fc5ecdd4552f36f77256e1fb53225801aff0

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy

$ uname -a
Linux WIN-GPNU4RS958T 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

@wimvanspringel
Copy link

I'm having exactly same issue as @Cteljr , same versions.
I tried fresh installing wsl2 and distros with same results:
X apps dont work, xeyes/xcalc: "cant open display :0" -or- "Missing X server or $DISPLAY"
I tried "export LIBGL_ALWAYS_INDIRECT=1" - not working...
Wayland apps do start normal (chrome/nautilus/gedit) but sometimes graphic garbles up, hinting at graphics driver problems

In /mnt/wslg/weston.log I see:
[16:58:42.737] Spawned Xwayland server, pid 23
[16:58:44.758] xserver crashing too fast: 134

Researching earlier reports of xserver crashing too fast in wsl2, turns up old intel graphic driver bugs.
I have a 2 GPU setup on an intel tiger lake i7:

  1. Intel® Iris® Xe Graphics
  2. Nvidia RTX 3050
    both with absolutely latest drivers (so I think), looks like the intel graphics driver crashes out on wsl2's xwayland

A solution is to get wsl2 to work with xming instead of wsl2's own xserver: install xming and add these to your .bashrc:
export WSL_WINDOWS_HOST=cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2
export DISPLAY=$WSL_WINDOWS_HOST":0"
That worked for me, but it seems you dont get the same fancy window integration

@wimvanspringel
Copy link

wimvanspringel commented Feb 15, 2024

Update:
Turns out I wasnt using the latest Intel Graphics drivers!
Intel's Driver Support Agent forced it to the old 27.20.100 latest manufacturer (MSI) supplied version.
Downloading latest install directly from intel's support site forced the install of latest 31.0.101 version
[edit] MS windows keeps resetting to the old driver, you need to use this trick to keep the new driver
Fixed all problems!
No longer need xming and wayland integrates much nicer with windows desktop

@WikiLiu
Copy link

WikiLiu commented Mar 15, 2024

If you have the same problem, look this method.
#1156

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

5 participants