Steps to rebuild a broken WSL environment after using Rancher#
Due to the fact that I had installed Rancher on Windows in the past, wsl install did not work properly and I was unable to use WSL2. This time, I was able to completely initialize and rebuild the WSL environment, so I will record the steps.
Background and situation of the problem#
I had previously introduced Docker Desktop and Rancher Desktop, and distributions such as docker-desktop and rancher-desktop were automatically added to the WSL virtual environment.
Even after uninstalling these, the wsl install command returned an error, making it impossible to install any WSL environment including Ubuntu.
The cause is probably that the internal state of WSL was corrupted.
approach to solution#
I completely initialized WSL and reinstalled it using the following steps.
Checking the current WSL status
wsl --list --all --verbose
Remove unnecessary distributions
wsl --unregister docker-desktop wsl --unregister docker-desktop-data wsl --unregister rancher-desktop
Completely disable WSL functionality
dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart
Performed a reboot.
Re-enabling WSL functionality
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Reboot again.
Reinstall WSL
wsl --install
Now you can install WSL distributions such as Ubuntu again.
Future policy and lessons learned#
Even after uninstalling Rancher Desktop or Docker Desktop, traces may remain inside WSL.
Initialization by setting `wsl –unregister` + `dism` was valid.
When switching virtualization-related tools on a development machine, you should also be careful about WSL state management.
In the future, I would like to consider periodically backing up using wsl –export in case WSL becomes corrupted.
Article information
- author:
Mr. Takagi
- Release date:
2025-07-05