microsoft / wslg

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

Error: Can't open display: :0 #1192

Open w93163red opened 5 months ago

w93163red commented 5 months ago

Windows build number:

10.0.22621.0

Your Distribution version:

22.04

Your WSL versions:

WSL version: 2.0.15.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.22621.3007

Steps to reproduce:

Did not have a clear step to reproduce. I have three WSLs in the host. Others are working fine, only the oldest cannot run

WSL logs:

stderr.log weston.log pulseaudio.log

WSL dumps:

core.weston.zip

Expected behavior:

should open x11 apps

Actual behavior:

image

Mospotato commented 4 months ago

This problem comes to me today, and I found that X0 does not exist in /tmp/.X11-unix/. ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/ solved my issue. Hope this could help someone.

mkolassa commented 3 months ago

This problem comes to me today, and I found that X0 does not exist in /tmp/.X11-unix/. ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/ solved my issue. Hope this could help someone.

Thank you, this was the temporary solution to my problem as well.

I had to re-create the symlink after stopping and starting my WSL Distro again, which is annoying but workable for now.

w93163red commented 3 months ago

image Mine have the X0 but still did not work

mkolassa commented 3 months ago

image Mine have the X0 but still did not work

Is X0 pointing to the correct location?

mkolassa commented 3 months ago

I ended up following these directions for a set-it-and-forget-it type solution...

https://gist.github.com/oleksis/871e185ff85b67e77565a214b163b0f0#init-tmpx11-unix-is-overwritten-by-mounts

mrunknown850 commented 3 months ago

This problem comes to me today, and I found that X0 does not exist in /tmp/.X11-unix/. ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/ solved my issue. Hope this could help someone.

Thank you, this was the temporary solution to my problem as well.

I had to re-create the symlink after stopping and starting my WSL Distro again, which is annoying but workable for now.

Have you tried to put the command in the WSL config so it run at startup yet?