1

I am running Windows 11 (version 22H2 build 22621.1485) and have been using a couple of Ubuntu distributions under WSL1 and WSL2 almost since they became available (Win 10 in the case of the WSL1 one).

Following a recent reboot of windows (unknown cause, might have been an enforced update). I find that even trivial use of WSL.exe fails. Only syntax parsing and help seem to work. e.g. wsl --help works but wsl --list fails:

Class not registered
Error code: Wsl/0x80040154

The error code is normally associated with "The error code The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again." But the subsystem has never been disabled. e.g. as illustrated in the following snippet

PS C:\Users\GrayG> wsl --list
Class not registered
Error code: Wsl/0x80040154
PS C:\Users\GrayG> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux                                                         

Path          :
Online        : True
RestartNeeded : False

PS C:\Users\GrayG> wsl --list
Class not registered
Error code: Wsl/0x80040154  

I have tried using the ancient "dependency walker" utility (http://www.dependencywalker.com/) to try to discover whether this is basically due to a sudden corruption of a DLL. But the walker seems never to complete its analysis of the dependency tree.

In an attempt to fix the app I have tried using Windows Setting: Apps > Installed apps > Windows Subsystem for Linux, and requested "Repair" under the Reset heading. This didn't seem to work.

Without knowing what to try to repair I am left thinking that it might be necessary to re-install wsl.exe. However there seems no way to do this without also losing my valuable Ubuntu images. In addition the only way I know to "save" these images, wsl --export, is unavailable for the obvious reason:

PS C:\Users\GrayG> wsl --export Ubuntu-20.04 c:\WSL-Export-Ubuntu-20.04.tar
Class not registered
Error code: Wsl/0x80040154

Even if I am prepared to lose these images I can see no safe method to re-install WSL, since the first step (e.g. of Completely reinstall WSL) is to use wsl.exe to uninstall individual distributions.

It may be that I should try Settings: Apps > Installed apps > Windows Subsystem for Linux "Uninstall". But I am not yet ready to try this before exploring other options.

The old method of installing a new WSL - to get a version of wsl_update_x64.exe (https://learn.microsoft.com/en-gb/windows/wsl/install) is a dead end since it refers to an older version of WSL (so that running it merely informs you that a later version of WSL is already installed).

So can anyone help:

  • diagnose the source of the "Class not registered" message
  • help find a way to fix the Wsl/0x80040154 error (given WSL is enabled)
  • show how to reinstall WSL without a functioning WSL.exe command

If so, I'd be very grateful.

4
  • WSL is very subject to Windows changes. Do you have a content backup that allows you to reinstall WSL?
    – John
    Apr 1, 2023 at 16:40
  • It may be relevant that WSL was updated to version 1.1.6 a few days previously. Apr 3, 2023 at 14:34
  • @John: unfortunately I do not have a content backup. Apr 3, 2023 at 14:36
  • Dependency walker won't help you. This is clearly a COM class and has no such mechanism (the whole point of COM). You could use the process monitor and watch HKEY_CLASSES_ROOT\CLSID for failures and backtrack from there using the missing GUID as your key. I see you have a solution (in yourself) but this is how you might have gone about figuring out Class not registered. Apr 3, 2023 at 15:09

3 Answers 3

3

I have found a solution to this issue, which will probably apply to the recovery of any WSL.exe package corruption.

The method is basically to re-install an earlier version of the WSL package and then update again to the current version.

It does not involve the loss of any existing VMs - it just fixes a corrupt version of wsl.exe.

To find packages of various ages execute:

wsl --release-notes

Or just go directly to https://github.com/microsoft/WSL/releases

Download the "current" package (you can find its version using "wsl --version"), and download and an older package.

You can not update to the current package, but you can re-install the older one (simply run it from explorer).

Once you have the older version you can then re-install the new one in the same way.

(This completely solved my issue.)

1
  • You're a hero! Thanks! I had your exact same issue on version 1.2.5, I just installed pre-release version 1.3.11 over it and it works again. Jul 2, 2023 at 10:25
1

WSL has stopped working recently for multiple people on my organization, myself included, and produced unexpected error codes. What worked for me was wsl --update followed by a Windows reboot.

1
  • Sadly, this is useless in my case: PS C:\Users\GrayG> wsl --update Checking for updates. The most recent version of Windows Subsystem for Linux is already installed. Apr 3, 2023 at 14:19
0

The Microsoft article Troubleshooting Windows Subsystem for Linux says this :

"Error: 0x80040154" after Windows update

The Windows Subsystem for Linux feature may be disabled during a Windows update. If this happens the Windows feature must be re-enabled. Instructions for enabling the Windows Subsystem for Linux can be found in the Manual Installation Guide.

The Installation Guide advises this :

Open PowerShell as Administrator (Start menu > PowerShell > right-click > Run as Administrator) and enter this command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

(This will work just as well in CMD.)

3
  • (As I'd hoped to illustrate in my question) Enabling the WSL feature (which I don't believe is disabled, in the first place) does not improve my situation (or change it, in any way). Apr 3, 2023 at 14:16
  • PS C:\Users\GrayG> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart Deployment Image Servicing and Management tool Version: 10.0.22621.1 Image Version: 10.0.22621.1485 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. PS C:\Users\GrayG> wsl --export Ubuntu-20.04 c:\WSL-Export-Ubuntu-20.04.tar Class not registered Error code: Wsl/0x80040154 Apr 3, 2023 at 14:32
  • In this bug report, the last comment says "I changed versions of Windows 11 from 22H2 to 21H2 and I don't appear to have the same issue". Your problem might just be a bug in 22H2.
    – harrymc
    Apr 3, 2023 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .