I have to work with WSL on Windows 10. Don’t judge me.
My old Ubuntu 18.04 used to work perfectly on WSL1 under a couple of conditions:
you add those to .bashrc or just execute them every time:
export DISPLAY=:0 export LIBGL_ALWAYS_INDIRECT=0 export GAZEBO_IP=127.0.0.1
(the last one is ROS-only, don’t worry about that if you are not using ROS+Gazebo)
and when starting VcXsrv remember either to use -ac parameter or in GUI:
– untick the middle option (OpenGL)
– tick the last option – unsecure connections, allow all
But my latest addition to the bunch, Ubuntu 20.04 (installed from Microsoft Store) returned a dreadful:
Error: Can't open display: :0
Let us have a quick look at the /etc/resolv.conf: (cat, grep only lines with nameserver in them, cut the ‘nameserver’ part out, leave the second with awk)
alice@DESKTOP-PVBMD9J:~$ cat /etc/resolv.conf | grep nameserver | awk '{print $2}' 172.17.86.193
Ok, that’s bad. What about a little mod?
ping 172.17.86.193 export DISPLAY=172.17.86.193:0 xeyes
… works.
To use in .bashrc:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0