microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.42k stars 822 forks source link

Can't update WSL2 #10527

Closed ealjkl closed 1 year ago

ealjkl commented 1 year ago

Windows Version

Microsoft Windows [Versión 10.0.22623.1325]

WSL Version

unkown

Are you using WSL 1 or WSL 2?

Kernel Version

unknown

Distro Version

any distro

Other Software

No response

Repro Steps

I try to run any wsl command in Power Shell or CMD.

E.g. $ wsl $ wsl --version $ wsl --update $ wsl --update --rollback etc.

Expected Behavior

It should perform the corresponding operation

Actual Behavior

I get in the terminal:

" WSL is finishing an upgrade... Update failed (exit code: 1603). Error code: Wsl/CallMsi/E_ABORT "

Diagnostic Logs

WslLogs-2023-09-21_18-15-02 (2).zip

WSL2 was working perfectly fine yesterday.

Today I got the error described in Actual Behavior. The odd thing is that I can create a new Windows account and run wsl --install and everything is fine; but as soon as I run wsl --update, I get the above error, and furthermore, I cannot use any wsl command.

The last build I had is: 22623.1 (gotten from running (gcm wsl).Version in Power Shell) The last kernel I had is: Linux 5.10.16.3-microsoft-standard-WSL2 (gotten from running wslfetch in my Ubuntu 20.24 instance)

Also I do have the wsl component turned on and the virtual machine features. And just in case I ran again:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart from the wsl install manual

OneBlue commented 1 year ago

This is a known issue if you run wsl --update in a non elevated terminal. This will be fixed in the next release.

In the mean time, running this command as administrator should fix the issue.

ealjkl commented 1 year ago

I tried running the terminal as an administrator, and from that terminal I ran the command does that count as running as administrator? or is there a command like sudo in Windows?

Anyhow, the problem was solved by itself after a day. Thank you a lot for your time!

NotConspicuous commented 1 year ago

I am also experiencing this, even on an administrative terminal, But I have the cause!

Product: Windows Subsystem for Linux -- Error 1406. 
Could not write value Name to key \SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE.  System error .  
Verify that you have sufficient access to that key, or contact your 
support personnel.

Ok, I didn't expect to make the world's most stubborn registry key. Took me about 30 minutes to regain ownership.

NotConspicuous commented 1 year ago

I have discovered a fix for you administrative issue in this regards, go into regedit and navigate to \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Terminal Server Client\ then select the DEFAULT key and take ownership via setting permissions, then delete it and re-create it.

WSL should proceed to allow you to install and update. This has not bricked my PC but please do note that playing with registry values is very risky and can brick your machine. I only do this because I have specific recovery software I can use. So please be cautious.

Have a nice day! 😄

OneBlue commented 1 year ago

I am also experiencing this, even on an administrative terminal, But I have the cause!

Product: Windows Subsystem for Linux -- Error 1406. 
Could not write value Name to key \SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE.  System error .  
Verify that you have sufficient access to that key, or contact your 
support personnel.

Oh that's interesting. @NotConspicuous could you share the complete install log file ?

NotConspicuous commented 1 year ago

I am also experiencing this, even on an administrative terminal, But I have the cause!

Product: Windows Subsystem for Linux -- Error 1406. 
Could not write value Name to key \SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE.  System error .  
Verify that you have sufficient access to that key, or contact your 
support personnel.

Oh that's interesting. @NotConspicuous could you share the complete install log file ?

Not really, this error originates on the event logger and no installer logs are left behind. This is as much as I can get. Some details here, It occurs because the user nor the system cannot edit the key \SOFTWARE\Microsoft\Terminal Server Client\Default due to some error reading it; not even regedit can add or view values inside the key (Possibly corruption? Cannot confirm.)

The error originates from the MSInstaller Service.

NotConspicuous commented 1 year ago

At least, no logs are left behind to what I can see.

OneBlue commented 1 year ago

Ok I see. You'd need to collect MSI logs manually.

Could try to downloading the MSI and install it via (elevated cmd.exe):

msiexec.exe /i <path-to-msi> /L*V C:\wsllogs.txt

and then share C:\wsllogs.txt

NotConspicuous commented 1 year ago

Ok I see. You'd need to collect MSI logs manually.

Could try to downloading the MSI and install it via (elevated cmd.exe):

msiexec.exe /i <path-to-msi> /L*V C:\wsllogs.txt

and then share C:\wsllogs.txt

This may be harder to reproduce since I have fixed the registry key, so I'd need to find a way to reproduce it again. Also, I doubt it's in control of the WSL project since it's more windows related.

I'll reproduce the settings by removing the permissions for TrustedInstaller to see it.

NotConspicuous commented 1 year ago

Here's the best I can give you, now I need to forcefully delete this key. AGAIN. wsllogs.txt

OneBlue commented 1 year ago

Unfortunately based on the logs it looked like the MSI was already installed so the logs don't actually show the registry error.

Can you try to completely remove the WSL from the control panel (there might be two installed packages, remove all of them), and collect logs again ?

NotConspicuous commented 1 year ago

Unfortunately based on the logs it looked like the MSI was already installed so the logs don't actually show the registry error.

Can you try to completely remove the WSL from the control panel (there might be two installed packages, remove all of them), and collect logs again ?

Right, I'll create a windows VM to recreate the issue. I don't feel like repeating safe mode... again.

NotConspicuous commented 1 year ago

@OneBlue Successfully reproduced perfectly on a clean VM. wsllogs.txt

This is reproducing a lack of permissions error I described by removing all perms to the key, also may be known as error 1603. Notice the identical Event Viewer Log.

image

OneBlue commented 1 year ago

Thanks a lot @NotConspicuous. I see the permission issue indeed:

MSI (s) (50:10) [02:49:37:851]: Executing op: RegOpenKey(Root=-2147483646,Key=SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE,,BinaryType=1,ControlRegistryReflection=0,)
MSI (s) (50:10) [02:49:37:851]: Executing op: RegAddValue(Name=Name,Value=C:\Program Files\WSL\WSLDVCPlugin.dll,)
MSI (s) (50:10) [02:49:37:851]: Note: 1: 1401 2: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE 3: 5 

Can you share a screenshot of the current permissions of that key ? The thing I'm trying to figure out is why this hits on your machine specifically.

NotConspicuous commented 1 year ago

Thanks a lot @NotConspicuous. I see the permission issue indeed:

MSI (s) (50:10) [02:49:37:851]: Executing op: RegOpenKey(Root=-2147483646,Key=SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE,,BinaryType=1,ControlRegistryReflection=0,)
MSI (s) (50:10) [02:49:37:851]: Executing op: RegAddValue(Name=Name,Value=C:\Program Files\WSL\WSLDVCPlugin.dll,)
MSI (s) (50:10) [02:49:37:851]: Note: 1: 1401 2: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE 3: 5 

Can you share a screenshot of the current permissions of that key ? The thing I'm trying to figure out is why this hits on your machine specifically.

Sadly I cannot reproduce the specific key's permissions or state beforehand for I don't know what they were in the first place. I'd assume Administrator not having the perms would cause this.

roskatom commented 1 year ago

I've had the same issues as above, relating to the same key. Interestingly, the key doesn't actually exist on my machine. I can't create it either, as I get a 'Cannot create a stable subkey under a volatile parent key.' error.

roskatom commented 1 year ago

Okay so it turns out that 'have you tried turning it off and back on again' really is the right answer sometimes! 😄 After posting the above comment, I rebooted my system. Post-reboot, the WSL upgrade completed successfully, and the previously missing registry key now exists.

NotConspicuous commented 1 year ago

Okay so it turns out that 'have you tried turning it off and back on again' really is the right answer sometimes! 😄 After posting the above comment, I rebooted my system. Post-reboot, the WSL upgrade completed successfully, and the previously missing registry key now exists.

Sadly, that wasn't the solution for me, but it does seem that there is a general issue with the key for some reason.

sarim commented 1 year ago

I have the same issue. Note that I upgraded wsl with wsl --update --pre-release many times before from normal pwsh without issue. But somehow this time it didn't work. The log "C:\Users\thegi\AppData\Local\Temp\wsl-install-logs.txt" here: wsl-install-logs.txt

Then From a administrator pwsh, I tried the same command. It says updated successfully, but afterwards wsl --version still shows 2.0.0.0. Tried twice, same issue.

Then run downloaded the msi from github release and run

msiexec.exe /i C:\Users\thegi\Downloads\wsl.2.0.1.0.x64.msi /L*V C:\wsllogs.txt

It showed a warning regarding WSL.lnk, but installed succesfully. And wsl --version now shows 2.0.1.0. Heres: wsllogs.txt

OneBlue commented 1 year ago

Thank you for reporting this @sarim. I could reproduce the issue and find its root cause. This will be fixed in the next release ! (although you will only see the fix in two releases, since the code that's "upgrading" needs to be fixed)

sarim commented 1 year ago

Thanks, glad to hear the issue has been identified :) So I need to download msi file manually and install it that way for next two releases?

OneBlue commented 1 year ago

Thanks, glad to hear the issue has been identified :) So I need to download msi file manually and install it that way for next two releases?

Either that, or installing via the store should work starting with the next release

obriat commented 1 year ago

I had trouble with 2.0.1.0 & 2.0.2.0: this comment fixes the problem https://github.com/microsoft/WSL/issues/10560#issuecomment-1739355815

OneBlue commented 1 year ago

Fixed with 2.0.3

nykbocks commented 11 months ago

im getting a bunch of problems with wsl2,so much that im planning to change to a live usb with puppy linux on it ...

heitormbonfim commented 10 months ago

Hi, I was having the same problem on my windows 10 pro. What worked for me was installing the WSL without a distribution wsl --install --no-distribution It installed the WSL, after that, I rebooted my computer As soon as I logged in, it was already installing ubuntu and it worked fine.

soutzis commented 10 months ago

Fixed with 2.0.3

No you didn't. Idk wtf is going on, not even 2.0.14 fixes anything

simonfontana commented 10 months ago

There is still an issue. Tried to install WSL yesterday and I received the 1603 error:

> wsl.exe  --install --no-distribution
WSL is finishing an upgrade... 
Update failed (exit code: 1603).
Error code: Wsl/CallMsi/E_ABORT

This is the log message I could find (Windows is not my primary system, I found this in Computer Management -> ... -> Windows Logs -> Application; let me know if that's incorrect):

Product: Windows Subsystem for Linux -- This application requires the Windows Subsystem for Linux Optional Component.
Install it by running: wsl.exe --install --no-distribution
The system may need to be restarted so the changes can take effect.

I have rebooted my system. Same issue and I can find no solution.

tilkinsc commented 10 months ago

My issue was that I didn't have have the lastest 21H2 and 22H2 patches. At some point microsoft threw in windows 11 upgrade as an option. This actively blocks you from updating windows to the later patches. More information on versions: https://learn.microsoft.com/en-us/windows/release-health/release-information

This following reg script will set your max upgrade level to 22H2. (To undo, its as simple as deleting/reverting the two values)

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate] "TargetReleaseVersion"=dword:00000001 "TargetReleaseVersionInfo"="22H2"


Open windows update (reopen if its already) it should look like this, notice the asterisk, except and it will want to update to windows 11.
![image](https://github.com/microsoft/WSL/assets/7494772/1fbac5f5-3c08-4343-a10b-99b4fa6252bd)

Pause and resume windows updates. This will trigger an update search and windows 11 will not come back. Simply update as normal. It took me through a couple of update restarts. I already had the latest wsl2 installed and could use it as normal.

WSL version: 2.0.14.0 Kernel version: 5.15.133.1-1 WSLg version: 1.0.59 MSRDC version: 1.2.4677 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.19045.3803

sarim commented 10 months ago

I had 2.0.1. Tried to update to latest just now several times from elevated powershell. Didn't work. wsl --version still shows the old one. Then I removed Windows subsystem for linux from add remove programs. then tried to wsl --install --no-distribution --web-download. It shows error. Later I just downloaded latest msi from github release and installed it. From changelog I see fixes related to upgrade, those will affect future upgrades I guess.

antgustech commented 6 months ago
PowerShell 7.4.2
PS C:\Users\xxxx> wsl --update
Checking for updates.
Updating Windows Subsystem for Linux to version: 2.1.5.
The handle is invalid.
Error code: Wsl/UpdatePackage/0x80070006

Running from elevated pwsh prompt.

proxseas commented 4 months ago

Fixed with 2.0.3

I tried various fixes and running the installed for "2.0.3.0" is the only one that worked. Manually installing the latest version (2.2.4.0 as of today) or running wsl --update breaks things. So I guess I will try to stay with this version as long as possible.

Subhadip05 commented 3 weeks ago

Solved #10527 :

Problem: When i enter "bash" or "wsl --version" on cmd. Could not write value InstallLocation to key \SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\MSI. Verify that you have sufficient access to that key, or contact your support personnel. Update failed (exit code: 1603). Error code: Bash/CallMsi/Install/ERROR_INSTALL_FAILURE

Solution : https://youtu.be/IRG8Ewz9lvA?si=3GevujhuTl3XtJDL

Yes my issue is fixed now.