Running GUI apps on WSL

Updating existing WSL installation

I updated WSL according to this MS guide:

wsl --update
wsl --shutdown
wsl --version
WSL version: 1.2.0.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.2604
wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
OracleLinux_8_5                        Oracle Linux 8.5
OracleLinux_7_9                        Oracle Linux 7.9
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
openSUSE-Leap-15.4                     openSUSE Leap 15.4
openSUSE-Tumbleweed                    openSUSE Tumbleweed

and tried gedit:

sudo apt update
sudo apt install gedit -y
gedit ~/.bashrc

but got:

(gedit:1854): Gtk-WARNING **: 19:49:45.422: cannot open display:

and the same with gimp:

sudo apt install gimp -y
gimp
Cannot open display:

I fixed this by running:

wsl --set-version Ubuntu-22.04 2

from PowerShell. The conversion took a hour or two, but finally succeeded:

For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion in progress, this may take a few minutes.
The operation completed successfully.

and the version become 2:

wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-22.04    Stopped         2

and I was able to run gedit and gimp:

but unfortunately, when I tried the same command:

wsl --set-version Ubuntu-22.04 2

on some other Windows 10 machine it failed with the following message:

For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion in progress, this may take a few minutes.
The operation could not be started because a required feature is not installed.
Error code: Wsl/Service/CreateVm/HCS_E_SERVICE_NOT_AVAILABLE

Also when I tried

wsl --install Ubuntu-20.04

on that machine I got:

Installing: Ubuntu 20.04 LTS
Ubuntu 20.04 LTS has been installed.
Launching Ubuntu 20.04 LTS...
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370114
Error: 0x80370114 The operation could not be started because a required feature is not installed.

Press any key to continue...
The installation process for distribution 'Ubuntu-20.04' failed with exit code: 1.
Error code: Wsl/InstallDistro/WSL_E_INSTALL_PROCESS_FAILED

Windows 10 version:

wsl --version
WSL version: 1.2.0.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.2604

but I fixed this by installing Virtual Machine Platform:

and the conversion completed successfully:

wsl --set-version Ubuntu-22.04 2
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion in progress, this may take a few minutes.
The operation completed successfully.

A clean installation

On some other Windows 10 machine I did the following in PowerShell:

wsl --install "Ubuntu-22.04"

and it started Ubuntu session in directly in PowerShell:

Installing: Ubuntu 22.04 LTS
Ubuntu 22.04 LTS has been installed.
Launching Ubuntu 22.04 LTS...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: def
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

This message is shown once a day. To disable it please create the
/home/def/.hushlogin file.
def@rigA:~$

and wsl -l -v command started to display version 2:

  NAME            STATE           VERSION
* Ubuntu-22.04    Running         2

and I was able to start Ubuntu session with the following command in PowerShell:

wsl --distribution Ubuntu-22.04 --user def

6 Responses to Running GUI apps on WSL

  1. dmitriano says:

    You need to install on Windows an X-server to be launched from Windows to be used by WSL graphical applications.
    https://superuser.com/questions/1580610/how-to-run-gui-apps-with-windows-subsystem-for-linux

    I chose to use VcXsrv in WSL (Windows 10 Subsystem for Linux). I recommend everyone do their research between xming (the accepted answer) and VcXsrv before selecting one or the other for Graphical User Interface (GUI) support in Windows 10 Ubuntu 16.04.
    https://askubuntu.com/questions/993225/whats-the-easiest-way-to-run-gui-apps-on-windows-subsystem-for-linux

  2. dmitriano says:

    Access WSL2 files from Windows: \\wsl.localhost\Ubuntu-22.04\home\dmitriano

Leave a Reply

Your email address will not be published. Required fields are marked *