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:
- I have also made sure that the Windows features are on: "Windows Subsystem for Linux" and "Virtual Machine Platform".
- 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
- Set the default version of WSL to 2:
wsl --set-default-version 2
- I already checked for updates for WSL, Windows and Ubuntu.
- 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: