microsoft / WSL

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

wsl.exe does not respond on Windows Server Core #10008

Open BrandonStudio opened 1 year ago

BrandonStudio commented 1 year ago

Windows Version

Windows Server 2022 Datacenter Core Azure Edition 10.0.20348

WSL Version

don't know

Are you using WSL 1 or WSL 2?

Kernel Version

don't know

Distro Version

don't know

Other Software

No response

Repro Steps

None of the below commands respond (exit immediately without any output):

wsl
wsl --install
wsl --status
wsl -l -v

But I do have wsl.exe:

> dir wsl.exe
 Volume in drive C is Windows
 Volume Serial Number is 94EA-2B6E

 Directory of C:\Windows\System32

04/09/2023  05:14 PM           184,320 wsl.exe
               1 File(s)        184,320 bytes
               0 Dir(s)  47,884,394,496 bytes free

When I try to install Ubuntu distribution manually following instructions here, I got this error message:

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates,     
dependency or conflict validation.                                                        
Windows cannot install package                                                            
CanonicalGroupLimited.Ubuntu_2204.1.7.0_x64__79rhkp1fndgsc because this package depends   
on a framework that could not be found. Provide the framework                             
"Microsoft.VCLibs.140.00.UWPDesktop" published by "CN=Microsoft Corporation, O=Microsoft  
Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor architecture   
and minimum version 14.0.24217.0, along with this package to install. The frameworks      
with name "Microsoft.VCLibs.140.00.UWPDesktop" currently installed ar                     
Windows cannot install package                                                            
CanonicalGroupLimited.Ubuntu_2204.1.7.0_x64__79rhkp1fndgsc because this package depends   
on a framework that could not be found. Provide the framework                             
"Microsoft.VCLibs.140.00.UWPDesktop" published by "CN=Microsoft Corporation, O=Microsoft  
Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor architecture   
and minimum version 14.0.24217.0, along with this package to install. The frameworks      
with name "Microsoft.VCLibs.140.00.UWPDesktop" currently installed are: {}                
NOTE: For additional information, look for [ActivityId]                                   
66806e04-39e0-0000-7537-17e40d75d901 in the Event Log or use the command line             
Get-AppPackageLog -ActivityID 66806e04-39e0-0000-7537-17e40d75d901                        
At line:1 char:1                                                                          
+ Add-AppxPackage .\Ubuntu_2204.1.7.0_x64.appx                                            
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                            
    + CategoryInfo          : WriteError: (C:\Users\Admin\....1.7.0_x64.appx:String) [Ad
   d-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Comm
   ands.AddAppxPackageCommand

And when I try to install VC runtime by this instruction, I got this error:

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF6, Package could not be
registered.
error 0x80040154: Cannot register the request because the following error was
encountered while initializing the windows.capability extension: Class not registered
.
NOTE: For additional information, look for [ActivityId]
66806e04-39e0-0000-bb37-17e40d75d901 in the Event Log or use the command line
Get-AppPackageLog -ActivityID 66806e04-39e0-0000-bb37-17e40d75d901
At line:1 char:1
+ Add-AppxPackage .\Microsoft.VCLibs.x64.14.00.Desktop.appx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\Users\Admin\...00.Desktop.appx:String) [Ad
   d-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Comm
   ands.AddAppxPackageCommand

Both Hyper-V and WSL feature are enabled.

Expected Behavior

see above

Actual Behavior

see above

Diagnostic Logs

No response

OneBlue commented 1 year ago

Thanks for reporting this @BrandonStudio. The error you're seeing is due to the fact that ServerCore doesn't support appx packages.

To install a distribution on serverCore, you can follow these instructions

BrandonStudio commented 1 year ago

@OneBlue I did follow that instruction, which told me to install the appx package

OneBlue commented 1 year ago

@BrandonStudio: The appx packages can't be installed on ServerCore, what you need to do is to download them manually and extract their content. You can find explanations on how to do that in the Install WSL on previous versions of Windows Server section of the link I shared earlier

BrandonStudio commented 1 year ago

@OneBlue Did you see the Add-AppxPackage in the link? image I've said that I got an error executing that, and have post the error here image

OneBlue commented 1 year ago

Ah you're right, I assumed that this documentation covered ServerCore but it actually doesn't. For this Edition you need to extract the .appx and manually import the distro. Here's how to do that with debian for instance (powershell):

curl.exe https://wslstorestorage.blob.core.windows.net/wslblob/TheDebianProject.DebianGNULinux_1.12.2.0_neutral___76v4gfsz19hv4.AppxBundle  --output debian.zip
mkdir $env:LocalAppData\lxss\debian
Expand-Archive .\debian\DistroLauncher-Appx_1.12.2.0_x64.appx
mv .\debian\DistroLauncher-Appx_1.12.2.0_x64.appx debian-inner.zip
Expand-Archive debian-inner.zip
wsl --import debian $env:LocalAppData\lxss\debian .\debian-inner\install.tar.gz --version 2

@craigloewen-msft : We should add a documentation page on how to do that

BrandonStudio commented 1 year ago

@OneBlue wsl.exe still exit immediately without any output I do think there are more than 1 problems, 'cause even wsl --help returns blank.

OneBlue commented 1 year ago

Thanks for following @BrandonStudio.

There's indeed an issue on Server Core SKU's right now where wsl.exe is crashing. We're working on backporting the fix.

Reopening to keep track of that issue.

DesktopECHO commented 1 year ago

This issue appears to be caused by KB5026370 (OS Build 20348.1726)

wusa /uninstall /kb:5026370

After a reboot, WSL is working again in Server Core 2022

573 commented 1 year ago

This issue appears to be caused by KB5026370 (OS Build 20348.1726)

wusa /uninstall /kb:5026370

After a reboot, WSL is working again in Server Core 2022

But the KB page mentions that:

Running Windows Update Standalone Installer (wusa.exe) with the /uninstall switch on the combined package will not work because the combined package contains the SSU. You cannot remove the SSU from the system after installation.

BrandonStudio commented 11 months ago

It seems this has been fixed, but my Windows version is still 10.0.20348.

I can now install Ubuntu 20.04 for wsl1, by directly running the unzipped ubuntu.exe.

I can't set wsl2 because my VM level does not support nested virtualization.

wsl --install and wsl --update is as expected unable to work, reporting "Class not registered"