wslg
wslg copied to clipboard
GUI not working with WSL2 + Ubuntu 24.10
Windows Version
Version 10.0.26100.2894
WSL Version
2.3.26.0
Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
Kernel Version
No response
Distro Version
Ubuntu 24.10
Other Software
No response
Repro Steps
After upgrading from Ubuntu 24.04 to Ubuntu 24.10, GUI stopped working. In python as example I get:
Traceback (most recent call last):
File "/home/grufoony/DynamicalSystemFramework/utils/get_osm_data.py", line 118, in <module>
ox.plot_graph(GRAPH, show=False, close=True, save=True, filepath="./original.png")
File "/home/grufoony/.local/lib/python3.12/site-packages/osmnx/plot.py", line 251, in plot_graph
fig, ax = _get_fig_ax(ax=ax, figsize=figsize, bgcolor=bgcolor, polar=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/osmnx/plot.py", line 1045, in _get_fig_ax
fig, ax = plt.subplots(figsize=figsize, facecolor=bgcolor, frameon=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/matplotlib/pyplot.py", line 1775, in subplots
fig = figure(**fig_kw)
^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/matplotlib/pyplot.py", line 1042, in figure
manager = new_figure_manager(
^^^^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/matplotlib/pyplot.py", line 552, in new_figure_manager
return _get_backend_mod().new_figure_manager(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/matplotlib/backend_bases.py", line 3501, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/matplotlib/backend_bases.py", line 3506, in new_figure_manager_given_figure
return cls.FigureCanvas.new_manager(figure, num)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/matplotlib/backend_bases.py", line 1783, in new_manager
return cls.manager_class.create_with_canvas(cls, figure, num)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grufoony/.local/lib/python3.12/site-packages/matplotlib/backends/_backend_tk.py", line 507, in create_with_canvas
window = tk.Tk(className="matplotlib")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/tkinter/__init__.py", line 2349, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: couldn't connect to display ":0"
Expected Behavior
Correctly opening the figure
Actual Behavior
Error
Diagnostic Logs
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here
Once completed please upload the output files to this Github issue.
Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.
View similar issues
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!
Closed similar issues:
- WSL2 Windows 11 suddenly cannot open display (#7950), similarity score: 0.72
- GUI Apps That Are Defaults With Linux Distro's Don't Work. (#8669), similarity score: 0.71
- wslg worked before, now doesn't seem to work. (#11864), similarity score: 0.71
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
EDIT: restarting the machine (not the WSL but the entire machine) I get the command xeyes working one time only. From the second exectution the error appears again
grufoony@Grufoony:~$ xeyes
grufoony@Grufoony:~$ xeyes
Error: Can't open display: :0
grufoony@Grufoony:~$
EDIT2: it seems to work more than one time (also restarting wsl) but for a limited amount time... it seems pretty random at the moment
Diagnostic information
Issue was edited and new log file was found: https://github.com/user-attachments/files/18489928/WslLogs-2025-01-21_12-45-09.zip
Detected appx version: 2.3.26.0
Thank you for reporting this @Grufoony. I wonder if there's an issue with X. Could you share the output of echo $DISPLAY when you see that error ?
Here it is:
grufoony@Grufoony:~$ echo $DISPLAY
:0
Ok thank you, this looks correct. Transferring to wslg to investigate further
I can confirm this issue on 5.15.167.4-microsoft-standard-WSL2 on WSL 2.4.10 after upgrade to 24.10 and that graphics was previously working before the upgrade. Using mirrored networking and Windows 11 24H2 (26100.3037).
I am experiencing this as well after upgrading to Ubuntu 24.10 under WSL2. xclip will work fine directly after a windows reboot but then randomly stop working with the following error message:
$ date | xclip
Error: Can't open display: :0
on 25.04 x11 apps not working but I can get Wayland (pretty much everything else) to work with the following commands
openssl genrsa -out ~/.weston-rdp-key.pem 2048
openssl req -new -x509 -key ~/.weston-rdp-key.pem -out ~/.weston-rdp-cert.pem -days 365 -subj "/CN=WestonRDP"
/usr/bin/weston --backend=rdp-backend.so --socket=wayland-0 --xwayland --rdp-tls-cert=~/.weston-rdp-cert.pem --rdp-tls-key=~/.weston-rdp-key.pem --shell=desktop-shell.so &
/usr/libexec/Xwayland :0 -listen unix &
export XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
export WAYLAND_DISPLAY=wayland-0
export DISPLAY=:0
export QT_QPA_PLATFORM=wayland
WSL isn't creating the environment for Ubuntu to start Wayland properly for some reason but I have no idea why.
seems like just setting up export XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir works for wayland apps (it takes some time but it loads), this could be related to https://github.com/microsoft/wslg/issues/57#issuecomment-826414337
Microsoft gotta give this more attention now that many people are facing this issue or similar:
- #1316
- #1317
- #1323
- #1324
- me, on my fresh install of Windows, WSL and Ubuntu 24.10
For me, after a wild goose chase, I found (with surprise) that the culprit is #43:
Ubuntu now ships upstream systemd’s
tmp.mountby default. In effect this means that/tmpis now atmpfsby default. ⸺ Ubuntu 24.10 release notes
$ mount | grep '/tmp'
none on /tmp/.X11-unix type tmpfs (ro,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,nr_inodes=1048576)
I found the fix in another thread
sudo rm -r /tmp/.X11-unix && ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix
ln -sf /mnt/wslg/runtime-dir/wayland* /run/user/`id -u`/
I was getting the same issue in Debian manually updated to 13.0 trixie, and the commands above fixed it for me
I found the fix in another thread
sudo rm -r /tmp/.X11-unix && ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix ln -sf /mnt/wslg/runtime-dir/wayland* /run/user/`id -u`/
This fixed the problem in Ubuntu 25.04 WSL2 as well. But there is another problem now - I need to be running the above 2 commands everytime I start the Ubuntu WSL2 🤕
Yup, agreed. The workaround fixes 25.04 on a clean WSL2 install, but has to be reapplied on restart.