I have been using Ubuntu on Windows via WSL for about a year and it works quite well.
The terminal I use for Ubuntu on Windows is wsltty, which is a thin wrapper around mintty and other tools for starting WSL sessions. Recently, when I start clicking the WSL Terminal icon, it start a Window and then quit silently.
By looking at the property of “WSL Terminal” icon, I find that the default command that wsltty uses to start the Ubuntu terminal is:
%LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= --configdir="%APPDATA%\wsltty" -~
In order to find possible error message, I did a little search. I find that we
can add the -h always
option to force the terminal window to stay open even
if there are some error in the process. The whole command is:
%LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= --configdir="%APPDATA%\wsltty" -~ -h always
The error message I saw is like the following:
wslbridge error: failed to start backend process
note: bash.exe output: Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
What?? I have apparently installed a WSL distribution. In order to confirm that, I find from here that the location for a WSL distribution is something like the following:
C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\
This is the directory where the root of the Ubuntu for Windows resides. I
opened the similar folder on my Windows and found that the rootfs
folder is
indeed gone!
Further dig reveals that the culprit is the Windows update, which has wiped out my WSL distribution somehow.
After knowing the causes, the solution is simple: just re-install a WSL distribution or just dump WSL and use Cygwin!