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.