6

I use Docker and WSL2 with an Ubuntu 20.04 distro on Windows 10.

For running programs in linux and getting the GUI in Windows I installed GWSL. Due to some troubles with it I uninstalled it and Ubuntu to set up all that again from scratch and resolve the issues.

Before I could start the WSL CLI window by opening the C:\Windows\System32\wsl.exe (either via the shortcut in the Windows Start or from the CMD / Power Shell / Git Bash). Now, when I start, the WSL command line window opens for less than a second and immediately disappears again.

What might cause this behavior and how to fix it?


Additional infotmation

> wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  Ubuntu                 Running         2
  docker-desktop         Running         2

WLS-Windows-Start

3
  • I could see several possible reasons, but I'd need some more detail (remember to edit your question to include this) -- First, provide the output of wsl -l -v. Second, how did you uninstall Ubuntu (there are at least four different ways)? Third, did you rerun the ubuntu.exe or Ubuntu from the Start Menu after reinstalling to have it configure the instance with the default username, password, (and most importantly) filesystem? Oct 14, 2021 at 14:39
  • Also, you mention running wsl.exe from the Start Menu. Do you mean the Ubuntu store app? The wsl.exe command never actually gets placed on the Start menu. Oct 14, 2021 at 14:46
  • @NotTheDr01ds Thanks for your comment. I've just added the info you asked for to the question. I uninstalled Ubuntu multiple times: from the "Programs and Functions" and from the start menu -- and installed it again. Last time I could not uninstall Ubuntu completely (and could not install it again then) a,d tried to complete the installation by editing the registry. Later I got the app uninstalled. So maybe broke something in the registry, and it prevents now starting WSL from Windows Start. The configs of the username was always the same, the iflesystem has not been configured explicitely.
    – automatix
    Oct 18, 2021 at 6:53

2 Answers 2

7

Given your wsl -l -v output, it looks like the docker-desktop-data instance got set as the default when you uninstalled Ubuntu. That's not actually a bootable instance, since it has no /init in it.

That hopefully will explain why the wsl command is exiting. Just running wsl.exe (from PowerShell, CMD, or the Start Menu) is attempting to launch docker-desktop-data and then immediately exits.

You should be able to fix it by executing wsl --set-default Ubuntu from PowerShell or CMD. If not, we can dig deeper.

1
  • Running wsl --set-default Ubuntu from PowerShell solved my issue with WSL restarting all the time when I was opening it. Jul 27, 2023 at 15:40
3

I had the same problem, in my case, I didn't have the Ubuntu distribution.

So, I installed it, using this command:

wsl --install -d Ubuntu

Then I used the following command to set the Ubuntu distribution as default:

wsl --set-default Ubuntu

Other useful commands:

# To list all installed distributions
wsl --list --verbose
wsl -l -v

# To see the available distributions to install
wls --list --online
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .