wslg
wslg copied to clipboard
Ubuntu 24.04 Wayland falling back to X11
Windows build number:
10.0.22621.0
Your Distribution version:
24.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.22621.3296
Steps to reproduce:
-
wsl --install Ubuntu-24.04
- setup account
-
sudo apt update
-
sudo apt install emacs-pgtk
(or other GTK app) -
emacs
WSL logs:
stderr.log weston.log pulseaudio.log
WSL dumps:
No response
Expected behavior:
Emacs or whatever GUI application to launch using Wayland and not Xwayland
Actual behavior:
Outputs the following and falls back to xorg display frames.
MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
Some more context if I try to explicitly set the GDK_BACKEND as follows I just get the following console output, no window is opened, and the program terminates.
> GDK_BACKEND=wayland emacs
(emacs:1152): Gtk-WARNING **: 09:26:41.236: cannot open display: :0
On 22.04 I do not need to use weston. I can also just use emacs without pgtk but this should be something that works
Due to a bug of systemd fixed in 24.04, you must do :
ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/
Or use an autostart conf : https://github.com/viruscamp/wslg-links
BTW, It's real that wayland working in 22.04@WSL depends a bug of systemd.
Yeah I'm not having any luck with the symlink.
This is still happening https://github.com/microsoft/wslg/issues/1244#issuecomment-2110655655
A weird quirk is that creating this symlink under your user account doesn't work (symlink is red in ls) but creating it when su'd into ubuntu the symlink creation works (symlink is blue in ls) but it still can't open the app.
The fix provided by @viruscamp makes emacs work on wayland instead of Xwayland:
Your ls -la $XDG_RUNTIME_DIR
output should be like above.
Thanks @viruscamp!
So yeah no dice still. My XDG_RUNTIME_DIR seems to be missing things when compared to your screenshot.
In the screenshot creating those links under my user account doesn't work. Creating the links under the ubuntu user works but it still can't open the display.
Perhaps I'm running into this issue https://github.com/ubuntu/WSL/issues/468 because I would have just used the ubuntu username but it complains that user already exists?
How are you installing 24.04? Are you updating from an existing 22.04?
Perhaps I'm running into this issue ubuntu/WSL#468 because I would have just used the ubuntu username but it complains that user already exists?
How are you installing 24.04? Are you updating from an existing 22.04?
I think you met the bug.
id avlec
id ubuntu
You can see that uid=1000 is ubuntu . WSLg works only for uid=1000. That another bug of WSLg.
Ubuntu's fix only applies to new install of 24.04.
Maybe there is only unstable and insecure method:
- manually edit /etc/passwd to swap uid
- chown uid for home of swapped user
Yes all of my attempts to use 24.04 on WSL have been fresh installs.
The fixes @viruscamp linked are working on the ubuntu user.
I'm just running into the user bug still with installing 24.04 fresh. (I removed the 24.04 app and reinstalled from winget) Is there some Windows or WSL update I have not gotten?
I guess the fixed wsl-setup package has not been put into the install image of ubuntu 24.04 for WSL.
We'd better wait them to publish a new image.
@avlec you're correct, wslg already starts a compositor:
Command line: /usr/bin/weston --backend=rdp-backend.so --modules=wslgd-notify.so --xwayland --socket=wayland-0 --shell=rdpr
ail-shell.so --log=/mnt/wslg/weston.log --logger-scopes=log,rdp-backend,rdprail-shell
Looks like the Ubuntu-24.04 switches to cloud-init and has user id=1000 defined in the cloud.cfg:
# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
# This will affect which distro class gets used
distro: ubuntu
# Default user name + that default users groups (if added/used)
default_user:
name: ubuntu
lock_passwd: True
gecos: Ubuntu
groups: [adm, cdrom, dip, lxd, sudo]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
and the installer is creating a user with id=1002 messing up wslg which is hardcoded to user id=1000.
If you want to fix it and use emacs-pgtk with wayland backend just edit /etc/group
and /etc/passwd
and switch IDs. You also have to edit the regkey and change DefaultUid
from 0x3ea
(1002) to 0x3e8
(1000). Look for the corresponding distro keys in \HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\
. Or, wait for the store package to be fixed.
emacs-pgtk works, after applying @viruscamp fix:
Yes @elsaco that's where we've gotten to. Just don't know what @zcobol did to have it working without hacking the user/groups.
Note: an easier hack is to create a 24.04 and use a throw away username and then just do the registry edit trick to change the DefaultUid then you can login as ubuntu and apply viruscamp's fix
@viruscamp is there any issue anywhere tracking the problem you fixed?
I just did a clean install of Ubuntu 24.04 and applied viruscamp's fix and
lrwxrwxrwx 1 ubuntu ubuntu 31 May 19 06:54 wayland-0 -> /mnt/wslg/runtime-dir/wayland-0
lrwxrwxrwx 1 ubuntu ubuntu 36 May 19 06:54 wayland-0.lock -> /mnt/wslg/runtime-dir/wayland-0.lock
Linls are valid
But when I run google-chrome as the ubuntu user (id: 1000) I get:
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen
Does anyone know why or have any suggestions on the best way to debug?
wsl --version shows:
WSL version: 2.2.2.0
Kernel version: 5.15.150.1-2
WSLg version: 1.0.61
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.22635.3640
I had a issue " Error: Can't open display: " when I tried to run applications. PS: I had already installed package x11-apps .
Resolved:
step 1: Windows 11, open Powershell with Run as Administrator, Command line: wsl --update
After updated, I opened WSL ubuntu 24.04 LTS and executed command line: xeyes
And GUI open in Windows.
I don't know if this will help you.
I get these strange errors, but xeyes works...
@mwoodpatrick Try to enable systemd
and the service from https://github.com/viruscamp/wslg-links, after restart wsl2 you may get chrome working.
To work around the user id issue, I used cloud-init customization
Created file
C:\Users\XXX\.cloud-init\Ubuntu-24.04.user-data
#cloud-config
users:
- default
- name: test
gecos: Test
groups: adm, admin, cdrom, floppy, sudo, audio, dip, video, plugdev, users, netdev
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
lock_passwd: false
plain_text_passwd: test
Then destroyed my wsl environment, and recreated it this way
# THIS WILL DESTROY THE CURRENT INSTALL
wsl --unregister Ubuntu-24.04
ubuntu2404.exe install --root
ubuntu2404.exe run cloud-init status --wait
wsl --terminate Ubuntu-24.04
wsl
Installed firefox, and it will be using xwayland
Apply the fix from @viruscamp
ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR
Firefox now runs fine with full wayland support
To make it run permanent, add it to /etc/bash.bashrc
(echo; echo'# FIX WSLG'; echo 'ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/') >> /etc/bash.bashrc
For bonus point, add that step to cloud-init
- (echo; echo'# FIX WSLG'; echo 'ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/') >> /etc/bash.bashrc
BUT what is still failing for me is glxgears (or google_chrome, ...)
$ glxgears
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen
UPDATE After further investigating this, I believe for better hardware support the usage of the GPU driver that supports WDDM 3.x is required. But that is only supported since windows 11. With windows 10 we are stuck on 2.7. And we are still on windows 10 enterprise. Check dxdiag in windows to see you current version
Would appreciate it if someone could test this with a WDDM 3.x driver on windows 11...
I'm on Debian (12.6) in wsl and emacs 29.2 doesn't launch per above, so it's not just an Ubuntu issue. I compiled emacs locally (using --prefix=<mylocaldirectory>
),
But confirm @viruscamp workaround works https://github.com/microsoft/wslg/issues/1244#issuecomment-2111712565.
I do not see authoritative Microsoft response / acknowledge of this issue nor in https://github.com/microsoft/WSL/issues/11261, is there anything else @Microsoft needs to attend this issue and fix it properly?
It may be very wrong, but can't I just set XDG_RUNTIME_DIR
to /mnt/wslg/runtime-dir
in /etc/profile
to fix the problem? what are disadvantages of that?
Would appreciate it if someone could test this with a WDDM 3.x driver on windows 11...
I get these messages still on windows 11, but glxgears works.
`$ glxgears MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
`
ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/
This command works for me. But I have to run it every time WSL restarts itself to open up the app, otherwise it doesn't open. So is there anyway I can automate it? If I add it into my zshrc it opens the "Oh No! Something went wrong" screen.
for Ubuntu, there is a packaged named =wsl-config=, I think it might be a good idea to integrate these tweaks into that, and also as a Debian user, I would love it if it could be migrated to Debian.
@wang1zhen
for Ubuntu, there is a packaged named =wsl-config=
Could you please send the link to that? I would love to check it out.
for Ubuntu, there is a packaged named =wsl-config=
Could you please send the link to that? I would love to check it out.
https://packages.ubuntu.com/noble/wsl-setup FYI. but this might be somehow off-topic I think.
I have similar issues. I was using Ubuntu 22.04 under wayland and now Ubuntu 24.04 runs under X11 for some reason. If anyone finds any solutions I'm interested.
@Souvlaki42 for now this command works
ln -sf /mnt/wslg/runtime-dir/wayland-* $XDG_RUNTIME_DIR/
@TarunDaCoder I think I've tried this before and didn't but after a fresh install of WSL2 it worked now.
It should be noted that this command should run in .bashrc
or .zshrc
though, because every time the instance is shut down, I need to do it again. Thanks for your solution non the less.
Hey, glad to hear it worked!
It should be noted that this command should run in .bashrc or .zshrc though, because every time the instance is shut down, I need to do it again. Thanks for your solution non the less.
Yeah, I am facing that issue as well, but if I put it in my .bashrc
or .zshrc
it shows me the "Oh No! Something went wrong!" screen and I'm not sure why.
@TarunDaCoder in the issue linked by @alonbl (https://github.com/microsoft/WSL/issues/11261), the issue description shows the steps to make a systemd oneshot service to create those symlinks, have you tried that workaround?