wslg icon indicating copy to clipboard operation
wslg copied to clipboard

GUI not working with WSL2 + Ubuntu 24.10

Open Grufoony opened this issue 10 months ago • 11 comments

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

WslLogs-2025-01-21_12-45-09.zip

Grufoony avatar Jan 21 '25 11:01 Grufoony

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:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Jan 21 '25 11:01 github-actions[bot]

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

Grufoony avatar Jan 21 '25 11:01 Grufoony

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

github-actions[bot] avatar Jan 21 '25 11:01 github-actions[bot]

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 ?

OneBlue avatar Jan 21 '25 22:01 OneBlue

Here it is:

grufoony@Grufoony:~$ echo $DISPLAY
:0

Grufoony avatar Jan 21 '25 22:01 Grufoony

Ok thank you, this looks correct. Transferring to wslg to investigate further

OneBlue avatar Jan 21 '25 22:01 OneBlue

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).

Lucent avatar Feb 10 '25 01:02 Lucent

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

davidscholberg avatar Feb 13 '25 07:02 davidscholberg

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.

nardholio avatar Mar 15 '25 02:03 nardholio

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

heav33n avatar Mar 30 '25 00:03 heav33n

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.mount by default. In effect this means that /tmp is now a tmpfs by 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)

ParadoxV5 avatar Apr 22 '25 19:04 ParadoxV5

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`/

Gabrielcarvfer avatar May 02 '25 08:05 Gabrielcarvfer

I was getting the same issue in Debian manually updated to 13.0 trixie, and the commands above fixed it for me

comiluv avatar May 13 '25 18:05 comiluv

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 🤕

vachu avatar May 24 '25 11:05 vachu

Yup, agreed. The workaround fixes 25.04 on a clean WSL2 install, but has to be reapplied on restart.

WarrenSchultz avatar May 27 '25 18:05 WarrenSchultz