Files
coco 8b94d76799 a
2026-07-21 13:57:15 +08:00

2.6 KiB

This is a very common error when running GUI apps (like gedit, firefox, GNOME apps, etc.) in WSL2 Ubuntu (especially Ubuntu 24.04). It happens because Mesa (the OpenGL implementation) tries to use the Zink driver (OpenGL over Vulkan) but fails to initialize the D3D12 backend that WSLg uses for GPU acceleration.Quickest Fixes (Try in This Order)

  1. Force the D3D12 Gallium driver (most effective for most people):

    bash

    export GALLIUM_DRIVER=d3d12
    

    Then launch your GUI app, e.g.:

    bash

    gedit
    

    or

    bash

    firefox
    

    To make it permanent, add this line to your ~/.bashrc or ~/.profile:

    bash

    echo 'export GALLIUM_DRIVER=d3d12' >> ~/.bashrc
    source ~/.bashrc
    
  2. Install missing libraries (often helps even if warnings remain):

    bash

    sudo apt update
    sudo apt install libgles2 libgl1-mesa-dri mesa-utils libglx-mesa0
    
  3. Fallback to software rendering (if the above doesn't work or you don't need GPU accel):

    bash

    export LIBGL_ALWAYS_SOFTWARE=1
    

    Add it to ~/.bashrc the same way as above.

Additional Steps if It Still Fails

  • Update everything and reboot WSL:

    bash

    sudo apt update && sudo apt full-upgrade -y
    

    Then from PowerShell (as Administrator):

    powershell

    wsl --shutdown
    

    Restart your WSL Ubuntu.

  • Make sure WSL is up to date: In PowerShell:

    powershell

    wsl --update
    
  • If you're on Ubuntu 24.04, some users report better stability by switching to Ubuntu 22.04 from the Microsoft Store (or installing it fresh).

  • For NVIDIA users wanting real hardware acceleration:

    • Ensure you have the latest NVIDIA driver on Windows.
    • Install CUDA on WSL if needed (see Ubuntu's official guide).
    • Sometimes the d3d12 driver still works better than native NVIDIA in WSLg right now.

Test if OpenGL is WorkingAfter applying a fix, run:

bash

glxinfo -B

You should see something like OpenGL renderer string: llvmpipe (software) or a D3D12-based renderer instead of Zink errors.The warnings may still appear but the app should launch normally. This issue has been ongoing for a while in WSLg + recent Mesa, but the GALLIUM_DRIVER=d3d12 workaround resolves it for the vast majority of users.Let me know your exact Ubuntu version (cat /etc/os-release), whether you're using NVIDIA/AMD/Intel GPU, and which GUI app fails — I can give more targeted advice.