Setting up WSL to allow the use of GUIs

The Windows Subsystem for Linux (WSL) now allows the easy use of QIIME 2 in the command line on a PC. While it is not necessary for QIIME 2, if you wish to use other programmes with graphical interfaces to analyse or view data generated by QIIME 2 (e.g. R studio or Spyder), some further set up is required beyond enabling WSL.

This quick tutorial facilitates this to allow more interactive use of the WSL.

GUI server installation

In windows (not the subsystem) install an X server of choice, this section uses VcXsrv, an open source server. Once installed, open VcXsrv, choose multiple windows, set display number to 0, select next, next, tick disable access control, finish. All other options remain default. The programme will have to be launched once every time one restarts their computer. It then runs in background so that once it has been started GUIs can be used as long as the computer remains on. If you save a .config file then launching is as simple as double clicking said .config file.

Next, in the WSL run the following commands to obtain packages necessary for the subsystem to host GUI programmes:

sudo apt-get install libxcursor-dev
sudo apt-get install alsa
sudo apt install libegl1-mesa libegl1

You will also need to configure the subsystem, open the bashrc congif file:

nano ~/.bashrc

Move to the end of this document and type:

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1

Then use CTRL X, Y, ENTER to save changes and leave. Close and re-open the terminal and you should now be able to launch GUI programmes, such as R studio, from the WSL (presuming that you have started the X server).

References

  1. https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2
  2. https://medium.com/@macasaetjohn/setting-up-a-spyder-environment-with-wsl-bb83716a44f3
1 Like