I’ve been trying to get graphical applications to work on WSL2. I started following the wiki instructions but things seem currently a bit more complicated that they were on WSL and the improvement @rbalint did in this wslu upload don’t seem enough.
The problem is known upstream and has to do with the fact that WSL2 has its own network configuration which means using localhost/127.0.0.1 to contact the xserver isn’t working.
I got it to work with those steps
Install an Xserver, I tried those options which work
x410 is available in the windows store with a free trial. Once started click on the systray icon and pick “Allow Public Access”
VcXsrv, download from https://sourceforge.net/projects/vcxsrv/ and install/start it. Specifying the server numer to be ‘0’ on the first screen and also allow public access
Disable Windows Defender Firewall for Guest or public Network (a better way would be to add firewall rules to allow only what is needed but I didn’t figure out how to do that yet, help welcome if anyone knows?)
doesn’t work.
On unbuntu the resolv.conf file contains the address of the real DNS used by the Windows 10 Pro and so the dislay variable contains the wrong address to be connected to for the X server
Strange on debian it still works outputting the display on the Ethernet adapter vEthernet (WSL):
Some hint to solve the problem?
I use Xming which is a Free Software X11 server. It allows to run full screen, full screen inside a window (with or without title bar, or each application on a different window and I export the DISPLAY by computing the variable value using the HOSTNAME environment variable and concatenating :0 to the value.
Hi,
Just installed WSL2 today have used WSL1 for a while.
The behaviour I see is that the WSL Virtual Adapter is the one that gets propagated to resolvf.conf so the scripts that use this to setup DISPLAY variable don’t work.
My solution is a quick python script that calls ipconfig.exe and tries to determine the active adapter from that.
drop it into your home folder from here https://gist.github.com/buxtonpaul/2074bc4c56f53cf37a27e3d59ca7a29b
and use it by adding
export DISPLAY=$($HOME/wsldisplay.py))
It should find the first adapter with a link-local address that is not the WSL Virtual ethernet
Thanks for you reply, i restart the session and ipconfig.exe run good now.
But new error , that’s look like python error, maybe some symbol or front are not understand.
Traceback (most recent call last): File "/home/romain/wsldisplay.py", line 5, in <module> for line in os.popen('ipconfig.exe'): File "/usr/lib/python3.8/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 53: invalid start byte
Ok, I think you are finding the limits of my python
I think what is happening is that you are running on a system with a non utf8 character set, and my code isn’t clever enough to handle it. I think that the popen command is supposed to be able select the correct settings for your locale, however I am wondering if the problem is that you have your windows set for one locale (I assume you use windows all the time and it is setup for where you live), and your linux installation is perhaps just defaulted to something, and it is this mismatch that is the problem?
if you run locale on your linux install, does it look like it matches what you would expect?
I confess I am a little out of my depth on unicode and python.