WSL: Starting WSL results in error "The file cannot be accessed by the system."
Version
Microsoft Windows [Version 10.0.22621.819]
WSL Version
- WSL 2
- WSL 1
Kernel Version
No response
Distro Version
Debian
Other Software
Docker Desktop (Windows), version 4.12.0 Visual Studio Code 1.73.1 (system setup) with Remote-WSL Extension 0.72.0
Repro Steps
Open powershell.
Run wsl.exe
Returned response is
The file cannot be accessed by the system.
Expected Behavior
It should start the distro.
Actual Behavior
Returned response is
The file cannot be accessed by the system.
Diagnostic Logs
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 60
I solved this issue by Reset the
Windows Subsystem for LinuxinApp Settings. I can’t access that setting page after resetting. but I remember what I did.Windows logo key -> type
linux-> 'Windows Subsystem for Linuxappears -> you can seeApp Settings` in the right pane, hit that menu.When Settings windows open, you can see the
Resetbutton. after the reset, It works like a charm!I was able to resolve my issue with a
dism /Online /Cleanup-Image /RestoreHealthand a restart.Removing Windows worked for me…
I am having the same error message since this morning, except it is only happening while using a remote ssh connection, if I start the command locally then they work, if I connect to windows using OpenSSH then type wsl then I get the error I am on insider build 25201.1000
Add or remove programs-> search forlinux->Advanced options->Repairfixed it for me.I have had this happen twice, last time I did the dism command and a couple of restarts and it eventually worked again, and now I have the same problem again. So I think that is not a permanent solution. And I think this issue should be reopened, there seem to be multiple people with an issue here.
Thanks @simmel . Removing
Windows Subsystem for Linuxworks to me.Tried it, did not work.
Using this other wsl.exe worked for me
Upgrading WSL to a pre-released version worked for me!
After rebooting it should be fine.
https://superuser.com/questions/1714736/cannot-run-wsl2-over-ssh-on-windows-11
@marklechtermann
Our case seems to be almost exactly the same as yours. We want to install a custom WSL image using a build agent. We noticed this issue with remote commands in Jan 2023 and found that no command with WSL at the front would work.
We use packer and powershell scripts to provision a windows sysprep image with WSL baked in. I do not know exactly what fixed the problem but we now do the following and it works fine:
I hope this helps.
For solution see #7900
I have the same issue. WSL works fine when executing from the usual graphical session but ends up with
The file cannot be accessed by the systemwhen using remote ssh session. The problem appeared approximately a month ago. Have no clue what could be the reason. No updates where applied or any configuration changes made.dismtool doesn’t help in my case. Windows version: 10.0.19045.2486. The issue definitely has to be reopened.I tried many things, repairing Windows, dism commands, sfc /scannow, uninstalling / reinstalling the Windows Subsystem for Linux optional feature of Windows, repairing my distro app, repairing the WSL store app, but the thing that finally worked was:
GUYS , this happens after a restore for some reason - nothing worked for me. the only simple thing was to uninstall windows subsystem for linux and reinstall it, this doesn’t cause any data loss - were not removing ubuntu , just the sub system app.so just remove it and reinstall from store. fixed easily
Just want to report that this solves my problem as well!!
I was running into this issue after switching my self-hosted build agent to run as a service. I tried many of the suggestions above without success. What worked for me was to modify my yml files to explicitly indicate the location of the WSL instance I want to execute:
variables: wslPath: '"C:\Program Files\WSL\wsl.exe"'From here, I modified the docker commands I was using like so:
'$(wslPath) docker buildx...Not ideal but currently the only thing working for me…
Yes! Exactly this happend to me - I had to restore the system and WSL broke. Wasn’t able to run the
wslcommand in Powershell to do anything (deleting and reimpoting my backup). I tried to remove and re-add theWindows Subsystem for Linuxsystem feature itself, but that didn’t help. Reinstalling the WSL app from the Microsoft Store fixed my problems. 🎉Resetworked for me and didn’t wipe the data, don’t worry if you’re afraid of losing data after doing a system restore and bricking WSL like meThis worked for me too. seriously, wtf???
@StephaneKazmierczak did you ever fix this issue?
I am experiencing the same issue. No matter which WSL command I run right after installing Ubuntu with wsl --install -d ubuntu, I get the same error. Distro: Ubuntu 22.04 Host: Windows 11 Enterprise (21H2 22000.1281) Powershell: 5.1.22000.832
I’m running the WSL commands from a ScheduledJob (powershell) after waiting for the initial user creation prompt, but having closed it without creating a user.
wow that saved the day thank you ❤️
I fixed it after installing wsl.msi manuall
Tried everything possible, none worked. Eventually this helped -
wsl --update --pre-releasewhich is funny! Stable version is Unstableif you get :
the solution was not “repair” for me or not only :
it was :
Since I’m on Windows Server 2022 I didn’t have a Reset option in the GUI so I tried Reset-AppxPackage with no luck. The version I was using was 2.0.14.0, but with -pre-release it went to 2.1.3.0 and my problems went away!
For others like me absolutely terrified at the thought of clicking uninstall for WSL, after backing up my vhdx to be safe (C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu<version and ID>\LocalState\ext4.vhdx) I did it, after uninstalling the 2 “Windows Subsystem for Linux” entries I had it immediately worked. I lost nothing, I didn’t have to do or re-install anything else, it just started working. ¯\_(ツ)_/¯
Another “fix” that doesn’t fix anything…
milo> ssh -Y cimmy@iris.local
Microsoft Windows [Version 10.0.22621.2428] © Microsoft Corporation. All rights reserved.
cimmy@IRIS C:\Users\cimmy>wsl The file cannot be accessed by the system.
cimmy@IRIS C:\Users\cimmy>
https://www.youtube.com/watch?v=T9r5d_YoIbc DISM.exe /Online /Cleanup-image /Scanhealth DISM.exe /Online /Cleanup-image /Restorehealth this worked for me!
Got this message on Windows 11. Nothing helped, even reactivation through the “Turn Windows features on or off” -> “Windows Subsystem for Linux” from the Control Panel.
The only thing that has helped is to delete “Windows Subsystem for Linux” by the Settings (“Add or remove programs” -> search for “linux”)
worked for me as well. Somehow my Windows got bricked during a restart. Then I had no other choice but to “restore” to a previous version and then following the above steps worked for me.
Thanks a lot ❤
I ended up following the steps to uninstalling that linux windows application, which did not uninstall wsl2, just got reverted to an older working version.