3

As a classroom for learning Unix/Linux, I'm using Microsoft's Ubuntu App in Windows 10. I want to run:

gedit somefile.txt

But I get the following:

Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
(gedit:27829): Gtk-WARNING **: cannot open display: :0.0

None of the following solutions have worked:

  1. As per this page I tried gksu gedit and just get the final line of the above error, and I tried sudo nano and can edit the file (but isn't really a solution as I want to use gedit).

  2. As per @WinEunuuchs2Unix's solution I downloaded VcXsrv, added export DISPLAY=localhost:0.0 to ~/.bashrc, installed ubuntu-desktop and yad and still get my original error when trying to open gedit.

  3. As per this page I installed Xming and vim-gtk and tried gvim instead of gedit and get:

    E233: cannot open display

  4. I followed this PC world tutorial probem-free up until dbus-launch --exit-with-session ~/.xsession, which gives me:

    /usr/bin/startxfce4: X server already running on display :0.0 xrdb: Connection refused xrdb: Can't open display ':0.0' xfce4-session: Cannot open display: . Type 'xfce4-session --help' for usage.

And now I don't know what else to try, so I'd love some help! I also hope this is a good question and apologize if I'm making a typical newbie error.

ThunderBird
  • 1,955
KMunro
  • 131
  • Did you try the xhost + command? – FedKad May 19 '19 at 10:39
  • @FedonKadifeli I didn't as it wasn't in the instructions I tried. So I just opened the Ubuntu app now and directly entered xhost + and xhost +myusername but in both cases I get xhost: unable to open display ":0.0". So it didn't help but does that help diagnose the issue? – KMunro May 19 '19 at 13:32
  • See this answer on github. Also, this question may be better suited for the https://superuser.com/ where questions about Windows are more on topic. Also, see this related question on unix.stackexchange.com. However, pay attention because answers/questions about this topic on WSL1 do not necessarily apply to WSL2 — you are most likely using WSL2. – mchid Jun 05 '22 at 23:43

2 Answers2

0

i recommend xhost + which is potentially dangerous as it lets anyone in the universe to connect to your X session, but you can run that then run your command, after the software starts up then run xhost - so you will be secure again. Thats a temprary workaround :)

anonym
  • 1
0

The Ubuntu app uses WSL which is primarily a text-based system, it does not provide a full-featured graphical desktop environment. However, since quite a while WSL is capable of running graphical applications in a window. The necessary steps on the installation and instructions how to use can be found in Microsoft's documentation.

If you are looking for a full-featured desktop, you may want to consider installing Ubuntu in a virtual machine, like e.g. Microsoft Hyper-V.

noisefloor
  • 1,086