Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl command outputs "The system cannot find the file specified." #5906

Closed
omdxp opened this issue Sep 11, 2020 · 55 comments
Closed

wsl command outputs "The system cannot find the file specified." #5906

omdxp opened this issue Sep 11, 2020 · 55 comments

Comments

@omdxp
Copy link

omdxp commented Sep 11, 2020

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.

@licanhua
Copy link
Collaborator

Look like the log is empty.

could you please dir %systemroot%\system32\lxss\tools\kernel to check if kernel exits? If not, please install the kernel

@omdxp
Copy link
Author

omdxp commented Sep 11, 2020

Look like the log is empty.

could you please dir %systemroot%\system32\lxss\tools\kernel to check if kernel exits? If not, please install the kernel

Here's the output:

C:\Users\asusi>dir %systemroot%\system32\lxss\tools\kernel
 Volume in drive C has no label.
 Volume Serial Number is 8005-36CF

 Directory of C:\WINDOWS\system32\lxss\tools

22/03/2020  23:29        60.754.360 kernel
               1 File(s)     60.754.360 bytes
               0 Dir(s)  15.577.899.008 bytes free

@spashii
Copy link

spashii commented Sep 14, 2020

Reinstalling the linux kernel and uninstalling other virtualization softwares(VirtualBox and VMware) solved it for me.

@nmelnick
Copy link

Piggybacking on this as I'm seeing the same issue, however, spashii's success did not work for me. My WSL is dead. :(

Logs: https://aka.ms/AA9p6ej

  • The kernel exists, but I attempted a reinstallation
  • Removing VMware player did not solve the issue, and no other virtualization is active
  • Removing WSL from the features list, rebooting, adding it, rebooting did not solve it
  • Attempting to remove Hyper-V failed and rolled back, despite removing all other feature dependencies and removing the network interface from device manager.

@omdxp
Copy link
Author

omdxp commented Sep 17, 2020

Piggybacking on this as I'm seeing the same issue, however, spashii's success did not work for me. My WSL is dead. :(

Logs: https://aka.ms/AA9p6ej

  • The kernel exists, but I attempted a reinstallation
  • Removing VMware player did not solve the issue, and no other virtualization is active
  • Removing WSL from the features list, rebooting, adding it, rebooting did not solve it
  • Attempting to remove Hyper-V failed and rolled back, despite removing all other feature dependencies and removing the network interface from device manager.

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? 😑😣

@licanhua
Copy link
Collaborator

From Logs https://aka.ms/AA9p6ej, the error is from HcnCreateNetwork. Likely it's Hyper-V issue

@nmelnick
Copy link

nmelnick commented Sep 22, 2020

Thanks, @licanhua . It looks like my Windows installation had an issue configuring network adapters, and that was one of the reasons that Hyper-V wouldn't uninstall so I could refresh it. Creating a new virtual switch in the Hyper-V Manager also failed miserably. Naturally, I went through the normal Windows steps of using sfc and dism to attempt to restore my system, but both found no issues. I attempted to uninstall all of my network adapters, but they would give me a code 56 every time they reappeared, even brand new ones.. Once I uninstalled the drivers for them, my HID devices also became unable to do class configuration, which left me without a keyboard. Feeling both desperate and stupid, I grabbed the release preview ISO of the 20H2 release of Windows 10 and did an in place upgrade with my working mouse, and shockingly, I'm now up and running again with working network adapters, Hyper-V, and WSL.

¯\(°_o)/¯

@licanhua
Copy link
Collaborator

licanhua commented Sep 22, 2020

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.

@sk0le
Copy link

sk0le commented May 10, 2021

I'm facing the same issue, and I'm thinking of resetting windows, but on wsl I have really important files, can I somehow export files or something else?

@omdxp
Copy link
Author

omdxp commented May 10, 2021

I'm facing the same issue, and I'm thinking of resetting windows, but on wsl I have really important files, can I somehow export files or something else?

Check if hyper-V is selected in Turn Windows features on or off

@bplasmeijer
Copy link

bplasmeijer commented Jul 1, 2021

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 2

For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The system cannot find the file specified.

wsl 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-wslconfig
image

Nice improvement on wsl CLI @benhillis, @craigloewen-msft

@MasturFYC
Copy link

if you install linux wsl on another disk and the disk not connected.. error occured

@ziruizhuang
Copy link

ziruizhuang commented Nov 8, 2021

Still present. Using WSL preview.

Default Distribution: Ubuntu
Default Version: 2
WSL version: 0.48.2.0
Kernel version: 5.10.60.1
WSLg version: 1.0.29
Windows version: 10.0.22000.282

Since there are possibilities that VM software is involved here, I do remember installing and uninstalling virtualbox between a working WSL and now a broken WSL. However, I cannot confirm that because I did not find a way to bring WSL back up and try to reproduce the problem yet.


Edit:
Tried disabling WSL and adding it back. No luck.


Edit:
Tried uninstalling VMWare. No luck.
Tried doing network reset from system Settings / Network & Internet / Advanced network settings / Network Reset. No luck at first, a bunch of Hyper-V adapters left behind. However, after letting it sit there over night, these Hyper-V adapters disappears and now I am able to successfully boot WSL. Now I have no Hyper-V adapters at all.

@Jaifroid
Copy link

I installed Ubuntu for VSL, from the Store, on Windows 11 some time ago and was using it happily. However, I messed up a node and npm upgrade inside Ubuntu and decided to uninstall and reinstall from the store. Uninstall and reinstall went smoothly, but now I get "The system cannot find the file specified" when I try to run Ubuntu in Terminal, and I'm thrown back into PowerShell. I haven't touched or opened Hyper-V between the uninstall and the reinstall of Ubuntu.

@Jaifroid
Copy link

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.

@TylerJaacks
Copy link

I'm also having this issue.

@LiterallyAClown
Copy link

LiterallyAClown commented Feb 6, 2022

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.

@SamJoan
Copy link

SamJoan commented Feb 6, 2022

I also have had this issue after no installations/uninstallations/anything. Worked fine ~12 hours ago

image

Changing the directory from the default value fixed it, to %USERPROFILE%.

@fourpastmidnight
Copy link

I also have had this issue after no installations/uninstallations/anything. Worked fine ~12 hours ago

image

Changing the directory from the default value fixed it, to %USERPROFILE%.

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-username and 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:

  1. If I open the Ubunto WSL distribution from the start menu not using WT, but using the standard CMD host, it works just fine.
  2. Because I haven't had any Windows update in over a year—long story, but a Microsoft Windows Update in late 2019, and again two more times in early 2020 completely ERASED ALL my personal files (i.e. My Documents, Downloads, etc.) on my work laptop; so yeah, I haven't been updating!

HTH someone else out there. There's a bug for this in the Windows Terminal project here.

@Kaira08
Copy link

Kaira08 commented Feb 22, 2022

I also have had this issue after no installations/uninstallations/anything. Worked fine ~12 hours ago

image

Changing the directory from the default value fixed it, to %USERPROFILE%.

Hey I am facing the same problem, how did you change the directory?

@mvvveen
Copy link

mvvveen commented Feb 22, 2022

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
image

@Kaira08
Copy link

Kaira08 commented Feb 22, 2022

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 image

That worked. Thank you!

@shivakumarchintala
Copy link

shivakumarchintala commented Feb 22, 2022

for me doing this worked
wslconfig /u Ubuntu-20.04 -> to unregister
unregistering the distribution and installing it again

@Xinnony
Copy link

Xinnony commented Mar 13, 2022

for me doing this worked wslconfig /u Ubuntu-20.04 -> to unregister unregistering the distribution and installing it again

wslconfig /u kali-linux and relaunch Kali linux work for me, thanks !

@roycebo
Copy link

roycebo commented Mar 15, 2022

Yes, I unregistered #kali-linux in #wsl using wslconfig /u kali-linux and relaunched the Kali-Linux app.

@WinstonN
Copy link

WinstonN commented Mar 23, 2022

I have the same issue, but I do not want to unregister my ubuntu and re-installing it again. I'll try to investigate more
I have also set my starting directory as %USERPROFILE% - but the bug still happens

@mrwiora
Copy link

mrwiora commented Mar 28, 2022

defining %USERPROFILE% solved it for me on a Server 2022 Terminal Server - THANKS!

@jmvcollaborator
Copy link

jmvcollaborator commented Apr 3, 2022

For the time being from the file C:\Users<UserName>.wslconfig comment this value.
#kernel=C:\temp\myCustomKernel

key value default notes
kernel string The Microsoft built kernel provided inbox An absolute Windows path to a custom Linux kernel.

Source : https://docs.microsoft.com/en-us/windows/wsl/wsl-config

@JDPhillips81
Copy link

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 image

You wouldn't know how to get to this in Windows 11, would you? 😅

@shtuseriff
Copy link

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.

You are a stud. This was my issue.

@xBlixon
Copy link

xBlixon commented Apr 25, 2022

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\blixon and so that starts in the home directory. So if someone wants to use it just set starting directory to \\wsl$\<linux>\home\<username>.

@dougkusanagi
Copy link

dougkusanagi commented Jul 14, 2022

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

@Sec-ant
Copy link

Sec-ant commented Aug 20, 2022

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\blixon and so that starts in the home directory. So if someone wants to use it just set starting directory to \\wsl$\<linux>\home\<username>.

@BlixonX Thanks, this solved my issue! but I hope someone can really fix this bug.

@kuhajeyan
Copy link

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 image

That worked. Thank you!

Solved it indeed.

@carlosorozcoremolina
Copy link

carlosorozcoremolina commented Sep 14, 2022

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:

  • Uninstall installed districts.
  • Uninstall Docker (if you have it)
  • Open your console in admin mode, and type:
    wsl -l
    to list the installed distros.
  • Remove all additional distros from the console with the following command:

wsl --unregister NAME_DISTRO

In 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 /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

Install kernel if you have it already installed, you should not install it again.

wsl --set-default-version 2

Now if you can install the distro you want from the Microsoft Store.

I hope it works for you! 🔥

@RC4347
Copy link

RC4347 commented Sep 29, 2022

image
just set this ~ symbols and it's works perfectly!

@kiranags
Copy link

kiranags commented Nov 4, 2022

My issue was quite different,
in WSL --list, I have ubuntu v20 but i have ubuntu v22 is Installed in my PC, so whenever i opened ubuntu v22, it says "system cannot find the file specified, what i did was:

  • Uninstall Ubuntu v22
  • Reinstall step by step of the kernel
  • Open PowerShell as Administrator
  • WSL --list
  • Check whether any existed ubuntu/linux is still there.
  • If exist, --unregister *the ubuntu (eg. wsl --unregister name)
  • I installed my Ubuntu V22 again from microsoft store, and it works

@yared51
Copy link

yared51 commented Dec 14, 2022

wsl

@yared51
Copy link

yared51 commented Dec 14, 2022

this worked for me

@sposec
Copy link

sposec commented Apr 3, 2023

Worked for me too

@QuinnCiccoretti
Copy link

I got this error when I manually disabled Hyper-V. I turned it back on and it worked

@wuxu92
Copy link

wuxu92 commented Jun 30, 2023

the Repair Function in settings Fixes the Issue for me:
image

@mym4y4
Copy link

mym4y4 commented Jul 19, 2023

Following steps worked for me:

Uninstall Ubuntu for wsl.
Reset terminal terminal (deleting it's data)
Reboot
Open terminal App and delete Ubuntu profile
Re-install Ubuntu for wsl

@JimmyJamTQBD
Copy link

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

I was experiencing the same issue and this was the only thing that worked for me

@liudonghua123
Copy link

Yes, I unregistered #kali-linux in #wsl using wslconfig /u kali-linux and relaunched the Kali-Linux app.

This works for me. You saved me a lot of time, thanks! After I execute wslconfig /u kali-linux, I need to open kali-linux from ms store to initialize the app.

image

@m15kh
Copy link

m15kh commented Aug 29, 2023

i run my ubuntu as run as administer
and work for me

@kossnocorp
Copy link

Had this problem after having a bluescreen on startup caused by a driver's conflict after installing a PCIe device. #5906 (comment) solved the problem for me

@bsqsbylt
Copy link

bsqsbylt commented Sep 5, 2023

I can fix my wsl by this way.
图片

@wackzingo
Copy link

This might sound dumb but it took me a long time to figure out where everyone was setting the starting directory and was looking in Control Panel. It's in the Windows Terminal Settings menu then click your Ubuntu or Linux distro profile. Fixed it for me.
image

@vosooghi
Copy link

After upgrading the Docker Desktop, I encountered this problem. I restarted my laptop two times, and it worked.

@edison12a
Copy link

Note:
It seems to me that one can not have Ubuntu22.04 without having the base Ubuntu wsl installed.
I landed into this issue because I uninstalled the base Ubuntu.

To fixthe issue:

  • I reinstalled the "Windows subSystem for Linux" windows store app which I had uninstalled. shoot!
  • I reinstalled the Ubuntu wsl and set my computer to use ubuntu22.04 as default.

@szantopeter
Copy link

szantopeter commented Dec 8, 2023

In my case the issue was that wsl.exe wants to start the windows service named WSLService and it couldn't find the executable. The solution was to open regedit and change this

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WSLService\ImagePath

to point to the correct location :

"C:\Program Files\WSL\wslservice.exe"

@EricBuist
Copy link

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.

@ArmandoBarron
Copy link

Hi everyone,

I had the same issue with my WSL. My problem was as follows:

  • I couldn't open WSL from the terminal (cmd or PowerShell).
  • I managed to open Ubuntu from the WSL shortcut.

To solve it, I did the following:

Go to installed applications and look for Linux (sorry if the screenshot is in Spanish).
image

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.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests