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

https://1drv.ms/u/s!ArYWk3X9lH3jicFEE6GNcS0tDY6Dtg?e=6VEqXD

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 60

Most upvoted comments

I solved this issue by Reset the Windows Subsystem for Linux in App 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 Reset button. after the reset, It works like a charm!

I was able to resolve my issue with a dism /Online /Cleanup-Image /RestoreHealth and 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 for linux -> Advanced options -> Repair fixed 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 Linux works to me.

Just want to report that this solves my problem as well!!

I solved this issue by Reset the Windows Subsystem for Linux in App 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 Settingsin the right pane, hit that menu. When Settings windows open, you can see theReset` button. after the reset, It works like a charm!

This worked for me too. seriously, wtf???

Tried it, did not work.

variables: wslPath: '"C:\Program Files\WSL\wsl.exe"'

Using this other wsl.exe worked for me

Upgrading WSL to a pre-released version worked for me!

wsl --update --pre-release

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:

  1. wsl --install
  2. RESTART
  3. Download the appx package directly from https://aka.ms/wslubuntu2004
  4. unpack the AMD64 package to get exe file.
  5. Start-Process “Installer\ubuntu.exe” -Verb runAs -ArgumentList ‘install --root /qn /quiet /log C:\logs\wslubuntu.txt’ -wait
  6. After installation, we customise our WSL build.
  7. We then export to a tar and unregister before reimporting to a central location (you may not have to do this)
  8. RESTART
  9. Slightly unrelated but we then had to remove the appx package with the following code otherwise sysprep would not work:
$wslAppxToDelete = Get-AppxPackage -AllUser | where-object {$_.name -match "MicrosoftCorporationII.WindowsSubsystemForLinux"}
Remove-AppxPackage -Package $wslAppxToDelete.PackageFullName -AllUsers

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 system when 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. dism tool 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:

  • Uninstalling “Windows Subsystem for Linux” (it’s a store app but you can only see it by typing “linux” in “applications and features” in Windows settings)
  • At this point, the wsl command worked again but advised to run “wsl update”
  • So I did, but that command fails miserably (“/bin/bash: line 1: update: command not found”) because it’s actually “wsl --update”
  • Running “wsl --update” installs again the store app
  • Finally working and I did not loose my distro!

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 solved this issue by Reset the Windows Subsystem for Linux in App 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 Reset button. after the reset, It works like a charm!

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…

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

Yes! Exactly this happend to me - I had to restore the system and WSL broke. Wasn’t able to run the wsl command in Powershell to do anything (deleting and reimpoting my backup). I tried to remove and re-add the Windows Subsystem for Linux system feature itself, but that didn’t help. Reinstalling the WSL app from the Microsoft Store fixed my problems. 🎉

Reset worked 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 me

Just want to report that this solves my problem as well!!

I solved this issue by Reset the Windows Subsystem for Linux in App 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 Settingsin the right pane, hit that menu. When Settings windows open, you can see theReset` button. after the reset, It works like a charm!

This worked for me too. seriously, wtf???

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

@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.

I fixed it after installing wsl.msi manuall

wow that saved the day thank you ❤️

I fixed it after installing wsl.msi manuall

Upgrading WSL to a pre-released version worked for me!

wsl --update --pre-release

After rebooting it should be fine. https://superuser.com/questions/1714736/cannot-run-wsl2-over-ssh-on-windows-11

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!

Tried everything possible, none worked. Eventually this helped - wsl --update --pre-release which is funny! Stable version is Unstable

if you get :

The file cannot be accessed by the system

the solution was not “repair” for me or not only :

Add or remove programs -> search for linux -> Advanced options -> Repair

it was :

Add or remove programs -> search for linux -> Advanced options -> Reinitialize

Upgrading WSL to a pre-released version worked for me!

wsl --update --pre-release

After rebooting it should be fine.

https://superuser.com/questions/1714736/cannot-run-wsl2-over-ssh-on-windows-11

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. ¯\_(ツ)_/¯

https://www.youtube.com/watch?v=T9r5d_YoIbc DISM.exe /Online /Cleanup-image /Scanhealth DISM.exe /Online /Cleanup-image /Restorehealth this worked for me!

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”)

Add or remove programs -> search for linux -> Advanced options -> Repair fixed it for me.

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.

I solved this issue by Reset the Windows Subsystem for Linux in App 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 Reset button. after the reset, It works like a charm!

Thanks a lot ❤

Just want to report that this solves my problem as well!!

I solved this issue by Reset the Windows Subsystem for Linux in App 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 Settingsin the right pane, hit that menu. When Settings windows open, you can see theReset` button. after the reset, It works like a charm!

didn’t work.

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.