June 19, 2019
I had a occasion to test WSL2. I must say it’s working better than I expected. Docker isn’t supported that great but that’s another story.
If you’ve tried to run :observer.start from IEx in WSL2, you’ve probably encountered this error:
- In WSL2 console, set this export:
export DISPLAY=localhost:0
This will tell X11 programs where to display (:0 is the first local display that was started). I recommend you to add this line to your .bashrc (or any other shell), so you don’t have to remember next time you open WSL2.
- Open Cygwin terminal and run this command:
startxfce4 -- -listen tcp
This should open Xfce windows manager. Again, best to keep this as an alias. At that point you should see Xfce desktop.
- Go to Xfce desktop and open xterm (Programs -> run -> type xterm) and run:
xhost +localhost
This will allow any local programs to access X.
- Go back to WSL2 console and run IEx
iex(1)> :observer.start
:ok
I hope that helps :)