4

I'm running through the tutorial on: https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#5-install-and-use-a-gui-package

After installing X11 applications I try to follow the tutorial and open xeyes:

xeyes &

I get the following response:

Error: Can't open display
BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
rh1040
  • 41
  • 1
  • 1
  • 2
  • 1
    Welcome to Ask Ubuntu! Could you run `wsl.exe --version` and add the results in an [edit](https://askubuntu.com/posts/1449804/edit) to your question? Also, is there any more information in the error? If so, please copy and paste the full message. Thanks! – NotTheDr01ds Jan 11 '23 at 17:25
  • I tried this, but get an error message: --version: command not found However using a different command I can see that I am using WSL2 for Ubuntu, if helpful – rh1040 Jan 13 '23 at 16:31
  • 1
    Okay, so you are on a somewhat older release of WSL that doesn't support `--version`, and may not support GUI applications (if you are using Windows 10). See [Running GUI apps under WSL](https://askubuntu.com/questions/1389908/running-gui-apps-under-wsl) and my answer to a similar question for instructions on how to upgrade to the "Store" release of WSL on Windows 10. If that solves it, let me know by clicking the "This solved my problem" in the header. Otherwise, let me know via comment and we'll investigate further. Thanks! – NotTheDr01ds Jan 14 '23 at 05:12
  • I do see that the Ubuntu tutorial includes information on installing WSL from the Store, but you may have already had an older release installed and skipped that part. – NotTheDr01ds Jan 15 '23 at 04:25
  • This might help. https://github.com/microsoft/WSL/issues/6430 . https://stackoverflow.com/questions/61860208/running-graphical-linux-desktop-applications-from-wsl-2-error-e233-cannot-op – aqwertya Jun 02 '23 at 10:10

3 Answers3

5

I had the same problem. What I did was:

  1. close the terminal
  2. re-open a fresh terminal
  3. run wsl --update
  4. relaunch ubuntu ubuntu
  5. run xeyes &

This fixed my problem.

flarnrules
  • 51
  • 1
  • Alas, I tried this and it didn't solve the problem. Thanks very much for the suggestion nonetheless. – rh1040 Jan 13 '23 at 16:32
3

Open C:\Users\username\.wslconfig

Find the line: guiApplications=false and change it to guiApplications=true. If you can not find the line, add it in the file.

Restart your PC.

  • Thanks. Restarting only the wsl was sufficient for me. `wsl -shutdown` then `wsl`. No need to reboot. – bkakilli Aug 30 '23 at 20:22
0

if you use core i chip of F series(core i5-9400F), you must install GPU (ubutun version must be 20.04 or later) see: https://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#1-overview