Skip to content

Starting WSL results in error "The file cannot be accessed by the system." #9197

Closed

Description

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

Activity

  1. arothenhaeuser commented on Dec 2, 2022

    @arothenhaeuser

    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.

  2. StephaneKazmierczak commented on Dec 7, 2022

    @StephaneKazmierczak

    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

  3. taikodragon commented on Dec 7, 2022

    @taikodragon
    Author

    I was able to resolve my issue with a dism /Online /Cleanup-Image /RestoreHealth and a restart.

  4. AidanStrong commented on Jan 13, 2023

    @AidanStrong

    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

    stephane (@StephaneKazmierczak) did you ever fix this issue?

  5. MathanGeurtsen commented on Jan 16, 2023

    @MathanGeurtsen

    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.

  6. pavelgood commented on Jan 17, 2023

    @pavelgood

    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.

  7. simmel commented on Jan 18, 2023

    @simmel

    For solution see #7900

  8. pavelgood commented on Jan 19, 2023

    @pavelgood

    Thanks Simon Lundström (@simmel) . Removing Windows Subsystem for Linux works to me.

  9. StephaneKazmierczak commented on Jan 27, 2023

    @StephaneKazmierczak

    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

    stephane (@StephaneKazmierczak) did you ever fix this issue?

    I keep a wsl shell running on remote machine at all times. Also I was having more issues with 1.1.0 so downgraded to 1.0.3

  10. marklechtermann commented on Feb 16, 2023

    @marklechtermann

    Same problem with our Azure DevOps pipeline job.

    c:\agent> wsl --version
    The file cannot be accessed by the system.

    In our case, we want to install a custom WSL image on a build agent.
    Over a RDP connection the call to "wsl --version" works.
    Via the build agent (same user) it does not work anymore.
    The error exists since about the beginning of January 2023.

    As described in the known issues, calls to the WSL that originate from a session zero no longer works.
    For example, when something is started from a Windows service (ADOs agents or SSH-Daemon) .

    Does anyone know workarounds?

    https://learn.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues

    Release Notes for Windows Subsystem for Linux in the Microsoft Store
    Launching Windows Subsystem for Linux from session zero does not currently work (for example from an ssh connection).

  11. AidanStrong commented on Feb 16, 2023

    @AidanStrong

    Mark Lechtermann (@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.

  12. luceat-lux-vestra commented on Apr 1, 2023

    @luceat-lux-vestra

    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!

  13. appleternity commented on Apr 3, 2023

    @appleternity

    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!

  14. jmihalich commented on May 7, 2023

    @jmihalich

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

  15. 32 remaining items

  16. chandankushwahaa commented on Mar 13, 2024

    @chandankushwahaa
    • Go to FIle manager search bar type \\wsl$ - It will open the file directory of linux distribution
    • Open terminal and type
    • wsl --list --v : It will list all installed Linux distributions
    • wsl --unregister ubuntu - ubnuntu is the name it can be anything from the list
    • Again install ununtu from microsoft store

    It works for me

  17. gabsoftware commented on Mar 15, 2024

    @gabsoftware

    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!
  18. DmitrY66 commented on Mar 16, 2024

    @DmitrY66

    В моем случае проблема была решена одной простой командой: "wsl --shutdown". Значение ее можно посмотреть набрав "wsl --help". Может показаться странным, но это работает как сразу, так и после перезагрузки. Удачи!

  19. HumbleBee14 commented on Mar 22, 2024

    @HumbleBee14

    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

  20. bjagasia commented on Apr 2, 2024

    @bjagasia

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

    This worked after a system restore -- thank you.

  21. pengweiqhca commented on Apr 2, 2024

    @pengweiqhca

    I fixed it after installing wsl.msi manuall

  22. rayinfinite commented on May 8, 2024

    @rayinfinite

    I fixed it by clicking a reinstall button in Windows Subsystem for Linux app in Microsoft Store

  23. DonovanPS commented on May 11, 2024

    @DonovanPS

    In my case I managed to solve it in the following way:
    delete the folder: C:\Program Files\WSL
    If it does not allow you to eliminate, stop the wsl service, in the windows search engine you search for services and within the application you search for wsl and stop it

    After that you search for wsl in windows and it will reinstall the wsl and it no longer gave me the error

  24. plato1123 commented on Jun 5, 2024

    @plato1123

    I fixed it after installing wsl.msi manuall

    wow that saved the day thank you <3

  25. Useems commented on Jun 14, 2024

    @Useems

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

    It worked for me, resolved in less than 1 minute.

  26. herofahad777 commented on Jun 23, 2024

    @herofahad777

    Sub system app.so just remove it and reinstall from store

    Hi I'm also facing the same issue and uninstalled the WSL from windows. Now trying to install from microsoft store, please check below screen shot if I'm installing correct app.

    Need to uninstall image

    Need to install image

    Is this correct? Please let me know so that I can proceed.

    It worked thanks just needed to click repair, the internal windows repair functions for me are also broken i think

  27. robertoandrade commented on Jun 27, 2024

    @robertoandrade

    Had this very issue on a Windows 11 installation and after reading through all comments here I noticed that indeed the wsl.exe copies that get installed and are available on the standard PATH aren't really the actual executables, unless they get replaced or something gets changed after reboot/repair, but debugging through the instances of wsl.exe on the system:

    >where wsl.exe
    C:\Windows\System32\wsl.exe
    C:\Users\vagrant\AppData\Local\Microsoft\WindowsApps\wsl.exe
    
    >dir C:\Windows\System32\wsl.exe
     Volume in drive C has no label.
     Volume Serial Number is 6E9D-788A
    
     Directory of C:\Windows\System32
    
    02/25/2024  01:48 PM           196,608 wsl.exe
                   1 File(s)        196,608 bytes
                   0 Dir(s)  96,262,938,624 bytes free
    
    >C:\Windows\System32\wsl.exe --version
    The file cannot be accessed by the system.
    

    Since while running dir /s \wsl.exe found many other copies in many directories including C:\Program Files\WSL\wsl.exe I ended up testing executing the same command with that one:

    >"c:\Program Files\WSL\wsl.exe" --version
    WSL version: 2.2.4.0
    Kernel version: 5.15.153.1-2
    WSLg version: 1.0.61
    MSRDC version: 1.2.5326
    Direct3D version: 1.611.1-81528511
    DXCore version: 10.0.26091.1-240325-1447.ge-release
    Windows version: 10.0.22631.3155
    

    That file seems to be much bigger than the ones on the path:

    >dir /s wsl.exe
     Volume in drive C has no label.
     Volume Serial Number is 6E9D-788A
    
     Directory of C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.2.4.0_x64__8wekyb3d8bbwe
    
    06/21/2024  07:55 PM         3,633,088 wsl.exe
                   1 File(s)      3,633,088 bytes
    
     Directory of C:\Program Files\WSL
    
    04/25/2024  06:19 PM         3,633,088 wsl.exe
                   1 File(s)      3,633,088 bytes
    
     Directory of C:\Users\vagrant\AppData\Local\Microsoft\WindowsApps
    
    06/21/2024  07:56 PM                 0 wsl.exe
                   1 File(s)              0 bytes
    
     Directory of C:\Users\vagrant\AppData\Local\Microsoft\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_8wekyb3d8bbwe
    
    06/21/2024  07:56 PM                 0 wsl.exe
                   1 File(s)              0 bytes
    
     Directory of C:\Windows\System32
    
    02/25/2024  01:48 PM           196,608 wsl.exe
                   1 File(s)        196,608 bytes
    
     Directory of C:\Windows\WinSxS\amd64_microsoft-windows-lxss-wsl_31bf3856ad364e35_10.0.22621.2506_none_62c8e9f54a7fa6e6
    
    02/25/2024  01:48 PM           196,608 wsl.exe
                   1 File(s)        196,608 bytes
    
     Directory of C:\Windows\WinSxS\amd64_microsoft-windows-lxss-wsl_31bf3856ad364e35_10.0.22621.2506_none_62c8e9f54a7fa6e6\f
    
    02/09/2024  08:05 PM               344 wsl.exe
                   1 File(s)            344 bytes
    
     Directory of C:\Windows\WinSxS\amd64_microsoft-windows-lxss-wsl_31bf3856ad364e35_10.0.22621.2506_none_62c8e9f54a7fa6e6\r
    
    02/25/2024  01:48 PM               595 wsl.exe
                   1 File(s)            595 bytes
    
         Total Files Listed:
                   8 File(s)      7,660,331 bytes
                   0 Dir(s)  96,284,803,072 bytes free
    

    So not sure if the other ones are stubs or some sort of "symbolic link" to the actual ones but they don't seem to work out of the box after installing and rebooting.

  28. Knufle commented on Jun 3, 2025

    @Knufle

    I fixed it after installing wsl.msi manuall

    wow that saved the day thank you <3

    Just for future reference, I was also a victim of this weird error after a Windows 10 system restore that showed a weird error upon finishing. I tried what other people said above, Repair, Reset, none of them worked.

    What actually worked for me was reinstalling it like you suggested, thanks!

  29. shiftonetothree commented on Jun 29, 2025

    @shiftonetothree

    I delete this two file then fix this issue

    C:\Users\AI\AppData\Local\Microsoft\WindowsApps\wsl
    C:\Users\AI\AppData\Local\Microsoft\WindowsApps\wslconfig
    
  30. DanielAtCosmicDNA commented on Sep 4, 2025

    @DanielAtCosmicDNA

    After testing other solutions here, this was the only one that worked for me...

    I fixed it after installing wsl.msi manuall

    I tried the following solutions previously but unfortunately none of them worked:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions