3

Some time ago, I installed WSL and Ubuntu 20. I have a script that I want to run from Windows in this WSL; however, when I use most WSL commands from Powershell or Command Prompt in both Administrator or normal access, I get:

(base) PS C:\Windows\System32> wsl
Windows Subsystem for Linux has no installed distributions.
Use 'wsl.exe --list --online' to list available distributions
and 'wsl.exe --install <Distro>' to install.
Distributions can also be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
Error code: Wsl/Service/CreateInstance/GetDefaultDistro/WSL_E_DEFAULT_DISTRO_NOT_FOUND

However, if I list the distributions with wsl.exe -l -v, I get the distribution that I am using:

(base) PS C:\Windows\System32> wsl.exe -l -v
  NAME            STATE           VERSION
  Ubuntu-20.04    Stopped         2

Things that I tried + more description

I also can open a terminal in Ubuntu and do stuff there without any problem. I guess one of the possible solutions would be to install it again; however, I have already modified the Ubuntu environment to my liking, installing packages, git repositories, etc. It would take me some time to do that again into a new installation, and even then, I am not sure if that would fix the problem.

Has anyone experienced this? Does anyone know how to fix it?

Here are the things I have tried so far:

  1. I have also made sure that the Windows features are on: "Windows Subsystem for Linux" and "Virtual Machine Platform".
  2. Reset related features (from here) In Command Prompt as admin (it required multiple restarts):
    net start LxssManager & net stop LxssManager  & net start LxssManager
    Dism /online /Disable-Feature /FeatureName:Microsoft-Windows-subsystem-Linux
    Dism /online /Disable-Feature /FeatureName:Microsoft-Hyper-V-All
    wsreset.exe
    rd /s /q c:\Windows\SoftwareDistribution
    Dism /online /Enable-Feature /FeatureName:Microsoft-Windows-subsystem-Linux
    Dism /online /Enable-Feature /FeatureName:Microsoft-Hyper-V-All
    DISM /Online /Cleanup-Image /RestoreHealth
    
  3. Set the default version of WSL to 2: wsl --set-default-version 2
  4. I already checked for updates for WSL, Windows and Ubuntu.
  5. I installed a new Ubuntu with wsl --install and wsl now works and starts a session in Linux, but again, I would prefer to use the Ubuntu that I already have instead of this new one. With this new version, I get:
    (base) PS C:\Users\Zaida> wsl --list
    Windows Subsystem for Linux Distributions:
    Ubuntu (Default)
    Ubuntu-20.04
    

Information about the system/WSL/Linux distribution

Here is some info about my system:

(base) PS C:\Windows\System32> wsl --version
WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.2715

About Ubuntu itself:

zaida@home_PC:WSL_Ubuntu### lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

And about the app:

Specifications: Ubuntu 20.04 on Windows

1
  • I experienced the issue when I installed WSL but did not restart the PC. Commented Apr 15 at 17:39

1 Answer 1

4

After I finished the question, I realized what was wrong and that it was a REALLY easy fix. In the past, I had more WSL distributions but I deleted all the ones that I was no longer using. I guess that during that purge, I eliminated the one that was considered the "DEFAULT_DISTRO" and therefore, wsl could not start without it, even though there was a distro installed.

When I installed the new distribution, that one was considered default:

(base) PS C:\Windows\System32> wsl.exe --list
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
Ubuntu-20.04

Therefore, it was only needed to switch or indicate to WSL which distribution to use. I did that by running wsl -s <DistributionName> as indicated here:

(base) PS C:\Windows\System32> wsl -s Ubuntu-20.04
The operation completed successfully.
(base) PS C:\Windows\System32> wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Ubuntu

And that's it. Everything is working now!

I decided to leave the post up and add how I solved it, because every time I googled the error code: "Error code: Wsl/Service/CreateInstance/GetDefaultDistro/WSL_E_DEFAULT_DISTRO_NOT_FOUND", I only got results about new installations failing, and not about a working distribution not being detected. Hopefully, it helps someone else.

You must log in to answer this question.

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