wslg icon indicating copy to clipboard operation
wslg copied to clipboard

"Error: Can't open display: :0" fails to run a simple GUI program correctly

Open nguynkhn opened this issue 1 year ago • 3 comments

Windows build number:

10.0.22631.0

Your Distribution version:

22.04

Your WSL versions:

WSL version: 2.1.5.0 Kernel version: 5.15.146.1-2 WSLg version: 1.0.60 MSRDC version: 1.2.5105 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22631.3593

Steps to reproduce:

  1. Install the WSL distro using wsl --install
  2. Install the driver from this website
  3. Install the x11-apps package
  4. Run xeyes

WSL logs:

pulseaudio.log weston.log stderr.log

WSL dumps:

core.Xwayland.30.txt

Expected behavior:

The program should be launched with a graphical window

Actual behavior:

The shell outputs Error: Can't open display: :0

nguynkhn avatar May 31 '24 04:05 nguynkhn

I have same problem..... Cant open gimp.....

vinberg88 avatar Jun 19 '24 15:06 vinberg88

I sometimes run into this issue, usually restarting WSL will fix it, sometimes I have to restart multiple times.

I wonder if it is something wrong with the socket. Would be nice to have a workaround that doesn't require restarting WSL or of course if it didn't happen in the first place. I never ran into this a few months ago. It was either triggered by updating WSL or the Linux distribution.

terlar avatar Jul 17 '24 05:07 terlar

I ran into this just now, following the instructions at: https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg#x11-display-socket

$ ls -la /tmp/.X11-unix
total 72
drwxrwxrwx    2 root  root    60 Jul 17 12:18 .
drwxrwxrwt 1000 root  root 69632 Jul 17 23:10 ..
srwxrwxrwx    1 terje 1000     0 Jul 17 12:18 X0

$ sudo rm -r /tmp/.X11-unix
rm: cannot remove '/tmp/.X11-unix/X0': Read-only file system

$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.61+Branch.main.Sha.54f177d201aecda01347f952e01777c75480fc74
Built at: Tue Apr 2 20:52:28 UTC 2024
Mariner: VERSION="2.0.20240112"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: f227edd681479ec3cb2290a25d84d2d3462aebfa

$ rg 'failed to bind' /mnt/wslg/weston.log
1376:[23:06:22.867] failed to bind to /tmp/.X11-unix/X0: Address already in use
1667:[23:06:23.035] failed to bind to /tmp/.X11-unix/X0: Address already in use
1890:[23:06:23.126] failed to bind to /tmp/.X11-unix/X0: Address already in use
2046:[23:06:23.212] failed to bind to /tmp/.X11-unix/X0: Address already in use
2268:[23:06:23.313] failed to bind to /tmp/.X11-unix/X0: Address already in use
2512:[23:06:23.400] failed to bind to /tmp/.X11-unix/X0: Address already in use
2714:[23:06:23.507] failed to bind to /tmp/.X11-unix/X0: Address already in use
2937:[23:06:23.605] failed to bind to /tmp/.X11-unix/X0: Address already in use
3215:[23:06:23.699] failed to bind to /tmp/.X11-unix/X0: Address already in use
3383:[23:06:23.774] failed to bind to /tmp/.X11-unix/X0: Address already in use

Restarting WSL twice got it working again. The commands show a similar output. Even when it working seems it is not a symlink. But the socket is working and I don't get the Address already in use messages in the weston.log.

terlar avatar Jul 17 '24 21:07 terlar