WSL: wsl command outputs "The system cannot find the file specified."
Environment
Windows build number: 10.0.19592.0
Steps to reproduce
I was working on my Ubuntu with wsl but somehow now it’s not running and the output of my PowerShell is as follows:
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
* Ubuntu Stopped 2
PS C:\WINDOWS\system32> wsl -d Ubuntu
The system cannot find the file specified.
WSL logs: https://aka.ms/AA9maq4
Expected behavior
I was using Ubuntu distribution using WSL very often, but now it cannot even run.
Actual behavior
Somehow the distribution cannot run.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 55 (1 by maintainers)
i only solved with
wsl --shutdown // shutdown wsl wsl -l // list all distros wslconfig /unregister ubuntu // remove every distro, because for me none of them worked anymore wsl --install --distribution Ubuntu // reinstall Ubuntu
for me doing this worked wslconfig /u Ubuntu-20.04 -> to unregister unregistering the distribution and installing it again
I also have had this issue after no installations/uninstallations/anything. Worked fine ~12 hours ago
Changing the directory from the default value fixed it, to %USERPROFILE%.
Reinstalling the linux kernel and uninstalling other virtualization softwares(VirtualBox and VMware) solved it for me.
You change it by clicking the down arrow next to the tabs then settings then under profiles on the left hand choose your distro. Now on the right side there it says starting directory
Yep, I have the exact same error. I have had no recent updates installed, had Hyper-V installed for the longest time with a working WSL. Just went to update my distribution given the latest security updates for various distros, and got this error for Ubuntu. The default Starting directory is
~, but as @SamJoan points out, setting this to%USERPROFILE%allowed the distro to start. Then on a whim, I tried setting the Starting directory to/home/my-wsl-usernameand got the same error again. I don’t think there’s anything special about using%USERPROFILE%. Something is just broken in Windows Terminal when using a starting directory somewhere within the WSL distro. I’m fairly certain this is a Windows Terminal issue for two reasons:HTH someone else out there. There’s a bug for this in the Windows Terminal project here.
I did fix my problem.
I was not able to run wsl2 anymore, and not able to convert wsl 1 to 2.
PS C:\Users\bap> wsl --set-version kali-linux 2wsl was not able to pick up the kernel from
.wslconfig, which did not exist anymore. https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfigNice improvement on wsl CLI @benhillis, @craigloewen-msft
I think the main error is because the system has a distro selected that does not exist.
Had the same error, now I can solve it with the following steps:
wsl -lto list the installed distros.wsl --unregister NAME_DISTROIn NAME_DISTRO change with your distro. Delete each of the distros until you have none.
It will provide you with the following commands, execute them with the terminal in admin mode.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartdism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestarthttps://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msiInstall kernel if you have it already installed, you should not install it again.
wsl --set-default-version 2Now if you can install the distro you want from the Microsoft Store.
I hope it works for you! 🔥
I’m having the same issue, but it seems to be only a windows terminal issue. If I run the exact same command configured in the windows terminal profile directly in powershell, it works. vs code also can still connect to the wsl instance without problem.
I have no idea of the root cause because it just started happening today without having installed/uninstalled/reconfigured anything. Maybe something auto updated somewhere, who knows.
Update: it’s the “starting directory” in the windows terminal profile, which was set to ~ (which never worked anyway, the shell always launched into some windows directory). Apparently windows terminal tries to access it as a windows path and doesn’t find it.
When using
%USERPROFILE%as the starting directory (at least in my case) Ubuntu starts in/mnt/c/Users/Blixon. Since i rather keep home dir by default (~), i used some wacky workaround by setting starting directory to:\\wsl$\Ubuntu-18.04\home\blixonand so that starts in the home directory. So if someone wants to use it just set starting directory to\\wsl$\<linux>\home\<username>.Hi everyone,
I had the same issue with my WSL. My problem was as follows:
To solve it, I did the following:
Go to installed applications and look for Linux (sorry if the screenshot is in Spanish).
Uninstall the WSL weighing 136MB.
After that, the WSL command started working again, so I ran the command WSL --install. The distros I already had installed (including the Docker one) remained intact.
the Repair Function in settings Fixes the Issue for me:
OK, after uninstalling again, I noticed that there was still a profile for Ubuntu in Windows Terminal. So I went into Terminal and removed that profile. Then I rebooted the Windows machine for good measure, reinstalled Ubuntu from the store, and now it runs fine in Terminal. So at least one issue seems to be that uninstalling a WSL doesn’t remove the corresponding profile in Terminal, which it should do.
I tried all of this. Even reinstalling WSL completely doesn’t work. I’m starting to think parts of WSL are in the Windows system image and if such parts are corrupt, you have to completely reinstall Windows. This is a super brittle system then, because reinstalling Windows completely removes applications and settings. If we now have to install multiple copies of Windows in different virtual machines in case of such corruption, then WSL is moot and we should just use VMs instead.
I can fix my wsl by this way.
i run my ubuntu as run as administer and work for me
defining %USERPROFILE% solved it for me on a Server 2022 Terminal Server - THANKS!
If your Windows is 19041.508(@nmelnick was hitting), I believe it’s related to the known issue: kb4571756-breaks-hyper-v-synthetic-ethernet-port. You can check if windows\System32\VmSynthNic.dll exits or not, if not, follow above thread to workaround the problem.
Honestly, it didn’t work for me as well, now I’m not even working on WSL because of this issue. Why something great as WSL is full of bugs? 😑😣
Look like the log is empty.
could you please
dir %systemroot%\system32\lxss\tools\kernelto check if kernel exits? If not, please install the kernel