Open MatthewL246 opened 2 years ago
@OneBlue - could you please take a look?
Thanks for reporting this @MatthewL246
This could be caused by a mismatch in the CRT.
Can you please share the output of get-appxpackage | where {$_.Name.contains("UWP")}
in a powershell prompt ?
@OneBlue Here is the output:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\Matthew> get-appxpackage | where {$_.Name.contains("UWP")}
Name : Microsoft.VCLibs.140.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 14.0.29231.0
PackageFullName : Microsoft.VCLibs.140.00.UWPDesktop_14.0.29231.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.UWPDesktop_14.0.29231.0_x64__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Name : Microsoft.VCLibs.120.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X86
ResourceId :
Version : 12.0.40653.0
PackageFullName : Microsoft.VCLibs.120.00.UWPDesktop_12.0.40653.0_x86__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.120.00.UWPDesktop_12.0.40653.0_x86__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.120.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Name : Microsoft.VCLibs.120.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 12.0.40653.0
PackageFullName : Microsoft.VCLibs.120.00.UWPDesktop_12.0.40653.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.120.00.UWPDesktop_12.0.40653.0_x64__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.120.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Name : Microsoft.VCLibs.110.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 11.0.61135.0
PackageFullName : Microsoft.VCLibs.110.00.UWPDesktop_11.0.61135.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.110.00.UWPDesktop_11.0.61135.0_x64__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.110.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Name : Microsoft.VCLibs.110.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X86
ResourceId :
Version : 11.0.61135.0
PackageFullName : Microsoft.VCLibs.110.00.UWPDesktop_11.0.61135.0_x86__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.110.00.UWPDesktop_11.0.61135.0_x86__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.110.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Name : Microsoft.VCLibs.140.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X86
ResourceId :
Version : 14.0.30704.0
PackageFullName : Microsoft.VCLibs.140.00.UWPDesktop_14.0.30704.0_x86__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.UWPDesktop_14.0.30704.0_x86__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Name : Microsoft.VCLibs.140.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 14.0.30704.0
PackageFullName : Microsoft.VCLibs.140.00.UWPDesktop_14.0.30704.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.UWPDesktop_14.0.30704.0_x64__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Name : Microsoft.VCLibs.140.00.UWPDesktop
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 14.0.30035.0
PackageFullName : Microsoft.VCLibs.140.00.UWPDesktop_14.0.30035.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00.UWPDesktop_14.0.30035.0_x64__8wekyb3d8bbwe
IsFramework : True
PackageFamilyName : Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Ok I can see that the correct version of the CRT is installed so the problem is elsewhere.
Can you try running Dependency walker on C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe
?
I wonder if another dll is missing
@OneBlue When I try to run dependency walker on wsl.exe
, it freezes and then crashes. Is there another program I can try?
Maybe you could use those ModLoad outputs.
Ok, let's try a different approach. Does this succeed in an elevated powershell prompt ?
Start-Service WslService ; Get-Service WslService
Forget it, can see in the logs that the service is starting correctly. The issue is when starting wslhost.exe.
I'll have a deeper look tomorrow
Actually one more question: Does this reproduce with elevated and un-elevated command prompts ?
@OneBlue Yes, I have same problem and I can reproduce it in a elevated command prompt.
@OneBlue Check this:
@OneBlue Yes, the service starts successfully. The same problem occurs whether I use an elevated or non-elevated command prompt.
@minusium I have the same results, C:\Windows\System32\wsl.exe
and C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe
fail but C:\Users\Matthew\AppData\Local\Microsoft\WindowsApps\wsl.exe
works.
Thank you @MatthewL246. It's really interesting that you're seeing different behaviors between:
C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe
and C:\Users\Matthew\AppData\Local\Microsoft\WindowsApps\wsl.exe
. It might be that the reparse points are not configured correctly.
Can you share the output of:
get-acl "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe" | format-list
get-acl "C:\Users\Matthew\AppData\Local\Microsoft\WindowsApps\wsl.exe" | format-list
``` ?
@OneBlue Here is the output:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\Matthew> get-acl "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe" | format-list
Path : Microsoft.PowerShell.Core\FileSystem::C:\Program
Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe
Owner : NT AUTHORITY\SYSTEM
Group : NT AUTHORITY\SYSTEM
Access : BUILTIN\Users Allow ReadAndExecute, Synchronize
S-1-15-3-429212343-3647803101-1591801556-3956432790-4290114561-3840431764-837144133 Allow ReadAndExecute,
Synchronize
BUILTIN\Users Allow Read, Synchronize
NT SERVICE\TrustedInstaller Allow FullControl
S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204 Allow
ReadAndExecute, Synchronize
NT AUTHORITY\SYSTEM Allow FullControl
BUILTIN\Administrators Allow FullControl
NT AUTHORITY\LOCAL SERVICE Allow ReadAndExecute, Synchronize
NT AUTHORITY\NETWORK SERVICE Allow ReadAndExecute, Synchronize
NT AUTHORITY\RESTRICTED Allow ReadAndExecute, Synchronize
MATTHEW-LAPTOP\Matthew Allow ReadAndExecute, Synchronize
BUILTIN\Users Allow ReadAndExecute, Synchronize
Audit :
Sddl : O:SYG:SYD:AI(XA;ID;0x1200a9;;;BU;(WIN://SYSAPPID Contains "MICROSOFTCORPORATIONII.WINDOWSSUBSYSTEMFORLINUX_8W
EKYB3D8BBWE"))(A;ID;0x1200a9;;;S-1-15-3-429212343-3647803101-1591801556-3956432790-4290114561-3840431764-8371
44133)(A;ID;FR;;;BU)(A;ID;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;ID;0x1200a9;
;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;ID;F
A;;;SY)(A;ID;FA;;;BA)(A;ID;0x1200a9;;;LS)(A;ID;0x1200a9;;;NS)(A;ID;0x1200a9;;;RC)(A;ID;0x1200a9;;;S-1-5-21-33
0327545-1755506854-1264941450-1001)(A;ID;0x1200a9;;;BU)
PS C:\Users\Matthew> get-acl "C:\Users\Matthew\AppData\Local\Microsoft\WindowsApps\wsl.exe" | format-list
Path : Microsoft.PowerShell.Core\FileSystem::C:\Users\Matthew\AppData\Local\Microsoft\WindowsApps\wsl.exe
Owner : MATTHEW-LAPTOP\Matthew
Group : MATTHEW-LAPTOP\Matthew
Access : NT AUTHORITY\SYSTEM Allow FullControl
BUILTIN\Administrators Allow FullControl
MATTHEW-LAPTOP\Matthew Allow FullControl
Audit :
Sddl : O:S-1-5-21-330327545-1755506854-1264941450-1001G:S-1-5-21-330327545-1755506854-1264941450-1001D:(A;ID;FA;;;SY
)(A;ID;FA;;;BA)(A;ID;FA;;;S-1-5-21-330327545-1755506854-1264941450-1001)
PS C:\Users\Matthew> get-acl "C:\Windows\System32\wsl.exe" | format-list
Path : Microsoft.PowerShell.Core\FileSystem::C:\Windows\System32\wsl.exe
Owner : NT SERVICE\TrustedInstaller
Group : NT SERVICE\TrustedInstaller
Access : NT AUTHORITY\SYSTEM Allow ReadAndExecute, Synchronize
BUILTIN\Administrators Allow ReadAndExecute, Synchronize
BUILTIN\Users Allow ReadAndExecute, Synchronize
NT SERVICE\TrustedInstaller Allow FullControl
APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES Allow ReadAndExecute, Synchronize
APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES Allow ReadAndExecute, Synchronize
Audit :
Sddl : O:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464G:S-1-5-80-956008885-3418522649-1831038044-18
53292631-2271478464D:PAI(A;;0x1200a9;;;SY)(A;;0x1200a9;;;BA)(A;;0x1200a9;;;BU)(A;;FA;;;S-1-5-80-956008885-341
8522649-1831038044-1853292631-2271478464)(A;;0x1200a9;;;AC)(A;;0x1200a9;;;S-1-15-2-2)
I would not be surprised if it's a permissions issue since I have done the "take ownership of the WindowsApps folder" tweak in the past. I have since reverted it SYSTEM/TrustedInstaller ownership. I did keep read access for myself, as you can see, so that might be causing the problems.
Oh this is interesting. It could definitely affect this path.
Did you do that before or after installing WSL ?
What if you run (elevated powershell)
Remove-AppxPackage (get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux -Allusers) -AllUsers
And then install from the store again ? I wonder if that's enough to reset the ACL
@OneBlue I have done tweak several times. I remember doing it with Windows 10 after installing WSL 1 and 2 but before the WSL preview app was released. I did it again after the Windows 11 upgrade, which I think reset it, and after installing WSL preview from the store this time. I have only done it to view the files in WindowsApps
; I have not run any of those "Windows 10 debloater" scripts.
I have tried uninstalling and reinstalling WSL preview a couple times, but I have not tried running that command (with -AllUsers
) yet. I will do it now.
@OneBlue Unfortunately, removing the package and reinstalling does not solve the problem. I have also tried the "Repair" and "Reset" buttons in the Settings app, but they do not help either.
I did same to WindowsApps folder too, but I reverted it a long time before installing WSL and I never did that again.
Btw what does 0xlx means?
@MatthewL246 thanks for your replies, I think we figured it out.
So there are two issues here:
That's caused by the permission change you mentioned. I was able to reproduce this issue by changing the permissions of WindowsApps as well, and I was able to recover by doing the following actions:
C:\Program Files\WindowsApps
to NT SERVICE\TrustedInstaller
Remove-AppxPackage (get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux -Allusers) -AllUsers
The core issue is that if the permissions of the WindowsApps are not what's expected, the ACL's for wsl.exe & wslhost.exe are wrong, and the processes fail to start correctly.
You can check that the permissions are correct by running get-acl "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.49.1.23_x64__8wekyb3d8bbwe\wsl.exe" | Format-List
If you do NOT see something like:
my-machine\my-account Allow FullControl
Then the permissions are CORRECT.
This specific error triggers a bad code path in wsl.exe and ends up crashing. This will be fixed in the next release.
Anyway, thanks a lot for the high-quality issue @MatthewL246. Let me know if the above instructions to restore WSL work for you
@OneBlue Thanks for the fix! I'm glad that I was able to help with my high-quality issue, even if it was just caused by a configuration problem on my end. I hope that this issue can help anyone else who encounters this problem and googles it.
@minusium I'm just mentioning you so that you can see the fix.
C:\Program Files\
WindowsApps
and open properties, then open the advanced security options.NT SERVICE\TrustedInstaller
into the box, then click "Check Names" and OK.Remove-AppxPackage (get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux -Allusers) -AllUsers
get-acl "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe" | Format-List
and make sure that it is owned by NT SERVICE\TrustedInstaller
and that your user account does not have access.I have exactly the same problem. It all started after when I installed GWLS from store. Uninstalling it cleared the problem. Then I tried installing GWSL again and at first all was ok and everything worked as normal, Until I rebooted. Even after uninstalling GWLS again did not help.
Strangest is that if I open WSL preview or Ubuntu 20.04 from store, all works fine again until I reboot. Then I have to open the app from store again to make it work.
Hope this helps.
PS: Just further tested and confirmed again. Once I used Store to open the WSL preview APP WSL, shows running from terminal wsl -l -v. Everything then works as normal untill I shut down WSL with wsl --shutdown. Then problen persists again.
PS C:\Users\Developers> wsl {Application Error} The application was unable to start correctly (0xlx). Click OK to close the application.
Stating WSL by open app in store started WSL distro OK.
Closing all Windows shows WSL stopped.
PS C:\Users\Developers> wsl -l -v NAME STATE VERSION
Open again WSL app from STORE starts WSL PS C:\Users\Developers> wsl -l -v NAME STATE VERSION
Bottom line with this method is... You cannot close WSL Distro windows as WSL stops running.
@pupa57 Yes, that looks like the same issue I faced. Have you tried the tutorial for the fix I posted?
@MatthewL246 Yes, Thank you.
@MatthewL246 thanks for your the detailed discussion and the fix, which sort of worked, but didn't :(
Using your fix, I was able to get wsl -l -v
and wsl
working again, but when I tried wsl --import
it failed with the old familiar sting
jerry@DELL5570 c:\wsl>wsl --import dubu20 c:\wsl\dubu20 c:\wsl\dubuntu20.export.wsl
Import in progress, this may take a few minutes
{Application Error}
The application was unable to start correctly (0xlx). Click OK to close the application.
jerry@DELL5570 c:\wsl>wsl -l -v
NAME STATE VERSION
* ubu20 Stopped 2
jerry@DELL5570 c:\wsl>wsl
{Application Error}
The application was unable to start correctly (0xlx). Click OK to close the application.
Now, due to my lack of Windows knowledge, I wasn't able to clean up the WinApps folder as cleanly as I would have liked, in the end it looked like:
And I'm not sure what that Account Unknown... represents or how to delete it
Similarly, I am not sure if I need to remove the entries for Users or Administrators that would seem to apply to my account, but do not have the specificity you suggested was required.
For what it's worth, my journey towards this today started when I was trying to understand why I couldn't start a wsl session when I ssh'd into the Windows 11 host.
Eventually I discovered at that point that while I could get get wsl -l -v
to work from a powershell, I could not get it to work once I used Windows OpenSSH to ssh back into the same host.
> wsl -l -v
> ssh localhost
> wsl -l -v
Access is denied.
@jerryasher Unfortunately, I am not sure how to completely fix the problem. I would recommend just not touching the WindowsApps
folder for now and waiting for the fix to be released.
One suggestion is that you can use C:\Users\your-username\AppData\Local\Microsoft\WindowsApps\wsl.exe
instead of wsl.exe
in System32. You can try adding the above path to your Windows PATH environment variable.
This problem was not solved in WSL Preview version 0.50.2. The PATH
tweak (see above) still works though. Note: you might need to rearrange the order of the paths in the PATH
environment variable so that %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
takes precedence over C:\Windows\System32
.
Default Distribution: Ubuntu
Default Version: 2
WSL version: 0.50.2.0
Kernel version: 5.10.74.3
WSLg version: 1.0.29
Windows version: 10.0.22000.346
@MatthewL246 Maybe just deleting C:\Windows\System32\wsl.exe =)))
WSL does have a timeout right? I think this can be configured in the Insider builds if I'm not wrong - I see that \Users\DELL\AppData\Local\Microsoft\WindowsApps\wsl.exe
and \Windows\System32\wsl.exe
return the 0x1x
error for me when i open them from an elevated/othewise cmd/powershell - But if i right click the Start Menu shortcut and open the executable as admin , wsl seems to start without a hitch
I've tried and tested this on Ubuntu , Debian and Mint - and I've noted that the error occurs a lot more frequently on Debian and the least on Mint
This error does not seem to happen on my other device - which has the exact same Store version of WSL
I get the error when i "wake" up WSL from sleep - or when i execute wsl --shutdown && wsl -d Mint
I do notice that i get the error very rarely when i use the docker-desktop
distro ( though it's not very useful is it 😅?)
@ZeRealStig It's 0xlx, not "One", It's small L In new update, now it's 0x%ulx I guess there's a bug in string formatter so it shows the format string instead of putting real error code in its place.
Yes,thank you 😅
Sorry
Remove
It worked like a charm for me (after running it with elevated privs.) and wsl seems to be working again!
I replaced wsl.exe
with %LOCALAPPDATA%\Microsoft\WindowsApps\wsl.exe
in terminal settings.
see https://github.com/microsoft/WSL/issues/5408#issuecomment-994304255.
@liudonghua123 This is not a solution, it's a workaround. Here we have two bugs, one doesn't show the correct error code and another doesn't start wsl when you run C:\Windows\System32\wsl.exe.
This happened to me after I had to force shutdown my PC. wsl -l -v
works, but starting it doesn't. I had changed WindowsApps owner, but changed it back to no avail. Stock WSL works, the one that hands is the Preview.
{Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
[process exited with code 4294967295]
EDIT: I had to follow the fix to a T (making sure that each step worked correctly, I had a single file still under my account's ownership)
@hyoretsu You shouldn't touch WindowsApps if you have not done anything to it before
@minusium I had messed with it precisely because I was trying to fix a pior WSL issue (a 0xc0070005 error that I couldn't find anywhere)
I'm glad I could help with my tutorial. 😀
One thing I noticed in my testing is that if you made multiple modifications to the WindowsApps
folder, such as giving everyone in the Administrators
group access, you will need to revert all of the changes. Unfortunately, it can get very complicated with the various Account Unknown S-1-15-3-1024-(numbers)
accounts, and apparently, the permissions have to be perfect for WSL to work.
I can only recommend not touching the WindowsApps
folder if the tutorial does not work and using the alternate PATH workaround so that at least running wsl.exe
can work.
Also, I have noticed that WSL now outputs The application was unable to start correctly (0x%lx).
This appears to be a completely unrelated issue in the string formatter.
I found another workaround for this problem!
If you go to your Windows app settings and move the Windows Subsystem for Linux Preview app from your system drive to an external drive, this problem disappears. I suspect this is because my external drive's WindowsApps
folder has never been modified, so the security permissions are correct.
If you have modified your external drive's WindowsApps
folder, this trick might not work, but you can try creating another NTFS partition on your drive, assigning a new drive letter, and moving the WSL Preview app to that new partition. That should create a new WindowsApps
folder on that partition with correct permissions.
Note that you will need to keep this drive connected to your computer whenever you want to use WSL, or WSL will fail to start.
A bit of an update on this issue: WSL Preview version 0.56.2.0 will still fail to start if the security permissions for WindowsApps
are not perfect. However, due to a recent update, it is now impossible to move WSL Preview to an external drive, breaking the previous workaround. This means that you will have to use the PATH tweak workaround if you are unable to revert all of the WindowsApps
permission changes.
Here is a simple tutorial for the fix:
- Make sure that File Explorer is set to show hidden and system files.
- Open File Explorer to
C:\Program Files\
- Right-click
WindowsApps
and open properties, then open the advanced security options.- Remove any specific user accounts (usually with Full Control) from the list and click Apply.
- Click "Change" next to the "Owner:" line and accept the UAC dialog.
- Paste
NT SERVICE\TrustedInstaller
into the box, then click "Check Names" and OK.- Check the box next to "Replace owner on subcontianers and objects" and click OK.
- In an elevated PowerShell window, run
Remove-AppxPackage (get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux -Allusers) -AllUsers
- Reinstall the WSL Preview app from the Microsoft Store here.
- To check the permissions, run
get-acl "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\wsl.exe" | Format-List
and make sure that it is owned byNT SERVICE\TrustedInstaller
and that your user account does not have access.
@MatthewL246 even this doesn't seem to work for me :(
I also tried moving the WSL Store executable to and from my D:\
drive - but to no avail
Even after modifying the PATH variables and restarting it looks like the System32
wsl gets preference ..?
Still getting the same error
Is C:\Users\DELL\AppData\Local\Microsoft\WindowsApps\wsl.exe
a symlink for the current version of WSL (C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.56.2.0_x64_8wekyb3d8bbwe\wsl.exe
) ??
I have a C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.56.2.0_neutral_~_8wekyb3d8bbwe\wsl.exe
and a C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.56.2.0_x64_8wekyb3d8bbwe\wsl.exe
- this is normal right?
I'm not 100% sure how to fix that @zstg, but here are some ideas. The only workaround I know of right now (if the permissions fix doesn't work) is the PATH tweak, as Microsoft no longer allows the app to be moved to another drive after an update.
Even after modifying the PATH variables and restarting it looks like the System32 wsl gets preference ...?
Did you modify the System PATH variable like this so that your WindowsApps folder is on top? I believe that the System PATH always takes precedence before the User PATH, and the order of entries does matter.
Please note: I have not tested this on a system with multiple users. I do not know what sort of problems adding a user-specific path to the system environment variables can cause.
Is C:\Users\DELL\AppData\Local\Microsoft\WindowsApps\wsl.exe a symlink for the current version of WSL (C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.56.2.0_x64_8wekyb3d8bbwe\wsl.exe) ??
Yeah, it looks like a symlink, but I'm not 100% sure which WSL it links to.
I have a C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.56.2.0neutral~_8wekyb3d8bbwe\wsl.exe and a C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.56.2.0_x64_8wekyb3d8bbwe\wsl.exe - this is normal right?
It is just like that for me as well, so I guess that's normal for Store apps.
Finally: if all of this fails, you can just uninstall the WSL preview Store app. You won't be able to use newer WSL features, but at least WSL will be functional.
My PATH does indeed have the WindowsApps folder at the top
No problem, thanks a lot!!
Update: as far as I can tell, this issue has been completely fixed! Edit: Looks like this was just a change with my environment, not an actual fix.
I decided to disable the workaround today for no particular reason, and all of my WSL distributions are now fully working. I'm not sure which update fixed this problem because I kept the workaround enabled for a while, but it must have been some update between 0.56.2.0
and 0.60.0.0
.
If anyone else would like to confirm that the problem is solved, I will close this issue.
@MatthewL246 I still experience the issue with wsl 0.60.0.0
Havent tried the workarounds yet. But for me the error does not happen when I open the WSL Tab in Windows Terminal, but only then. Each other way to start WSL will crash with the mentioned error.
EDIT: The workaround with resetting owner of Windows Apps+ reinstall helps (worth adding that no data is lost on ubuntu, I was scared to try first) :D
@WtfJoke I'm glad the workaround worked for you!
However, it's unfortunate that the issue wasn't fully fixed upstream; my computer just somehow magically fixed my environment. I assume that in my case some Windows or Microsoft Store update just reset the permissions correctly, and now I am able to use WSL Preview without any problems or workarounds.
Version
Microsoft Windows [Version 10.0.22000.282]
WSL Version
Kernel Version
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
Distro Version
Ubuntu 21.10 (updated from Store release)
Other Software
N/A, just Windows Terminal
Repro Steps
wsl.exe --shutdown
wsl.exe
. Observe as it freezes for a second and then fails.ubuntu.exe
or click Ubuntu in the Start menu. Observe as it also fails.wsl.exe --status
orwsl.exe --help
. These commands succeed.wsl --shutdown
, notice that the problem reappears.Note: Uninstalling WSL Preview from the store and using the version of WSL 2 included in Windows prevents this problem.
Expected Behavior
WSL should always start successfully from both the command line and the Start menu.
Actual Behavior
WSL fails to start from the command line. When using Windows Terminal, it shows the error message of:
Note: Powershell thinks the error level is
-1073740791
.However, WSL does start when clicking "Windows Susbsystem for Linux Preview" from the Start menu but not when clicking "Ubuntu".
Diagnostic Logs
See diagnostic details
### My command history: ``` Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows PS C:\Users\Matthew> wsl --shutdown PS C:\Users\Matthew> wsl --help Copyright (c) Microsoft Corporation. All rights reserved. For privacy information about this product please visit https://aka.ms/privacy. Usage: wsl.exe [Argument] [Options...] [CommandLine] # Lengthy command output snipped PS C:\Users\Matthew> wsl --status 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 PS C:\Users\Matthew> wsl {Application Error} The application was unable to start correctly (0xlx). Click OK to close the application. PS C:\Users\Matthew> wsl {Application Error} The application was unable to start correctly (0xlx). Click OK to close the application. PS C:\Users\Matthew> echo $LASTEXITCODE -1073740791 PS C:\Users\Matthew> ubuntu --help Launches or configures a Linux distribution. Usage:Please let me know if there is anything else I can do to help you debug this issue.