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.

Gray Girling
  • 41
  • 1
  • 6

3 Answers3

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.)

Gray Girling
  • 41
  • 1
  • 6
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.

gronostaj
  • 58,482
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.)

harrymc
  • 498,455