WSL not working after update from Microsoft store

Version
Microsoft Windows [Version 10.0.19044.1586]

WSL Version
WSL 2

Kernel Version
5.10.16

Distro Version
Ubuntu20.04LTS

Other Software
Docker Desktop (Windows), version 4.6.1 (76265) Docker Engine v20.10.13

Repro StepsI already had WSL installed from Microsoft Store few days and it was working fine. I got an update about the WSL from Microsoft Store and I updated it then it stopped working.

Expected Behaviorbash shell. Windows Subsystem for Linux is already installed so it should operate normally.

Actual BehaviorHello I had successfully installed WSL few days ago and everything was working fine. But after the I got an update regarding WSL from Microsoft Store I updated WSL and since then it is throwing this error. I also restarted the computer and checked to make sure my Virtual Machine Platform and Windows Subsystem for Linux are ON and I found out that both of these services were already ON. still I get the same error. May I please get any guidance on this one? as I have to use WSL for my educational purpose that would be really helpful thanks

Installing, this may take a few minutes...<br>
WslRegisterDistribution failed with error: 0x80070050<br>
Error: 0x80070050 The file exists.
Press any key to continue...

Diagnostic Logs No response

0

4 Answers

A second possible answer based on the latest information. I cannot test this personally since I am not having the issue.

Please backup (using the steps I mention in my previous answer) before trying this.

  • wsl --shutdown (from PowerShell or CMD)
  • In Windows, run the Registry Editor
  • Find \HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss
  • Find the key in there that has DistributionName of Ubuntu20.04LTS. Change the Ubuntu20.04LTS to Ubuntu-20.04.

In theory, that may fix the problem by changing the distribution name back to what it should be.

10

Update: This answer was my first attempt at the solution (which does work), and the "safe" way of doing it. However, the "quick and easy" (but less "safe") registry edit that I posted as a second answer appears to be working for multiple users as well. This answer contains the background on the problem and why both of these techniques work for correcting it.

From reading through several Github issues (including, from the looks of it, one that you posted there), this appears to be a problem with the recent Store update of the Ubuntu app. The ubuntu.exe or ubuntu2004.exe (edit: I now believe this only happens with ubuntu2004.exe, but please let me know if you experience this on the ubuntu.exe version) is broken after update.

The ubuntu.exe command really does two things -- It first checks to see if Ubuntu is installed in WSL. If not, it extracts the Ubuntu rootfs and asks you to configure a username and password. If it's already installed, it launches WSL using that distribution.

The problem seems to have actually started in the previous version of the "Ubuntu 20.04" app in the Microsoft Store. The name of the distribution that is installed should be (historically), Ubuntu-20.04. The previous version appears to have had a bug where this was renamed Ubuntu2004.LTS (thanks @Pat for pointing this out in the comments).

This would have caused a similar problem for all users that updated. However, it seems Canonical quickly pushed a fix for the issue.

Unfortunately, if you installed during that window where the "bad version" was in the Store, then the fix breaks things for you, because now:

  • ubuntu2004.exe is looking for a distribution named Ubuntu-20.04.
  • It doesn't find it (because your version is incorrectly named Ubuntu20.04LTS), so it attempts to run the rootfs/configuration stage again. But the WSL files are already extracted and configured, leading to the error.

There are several options:

  • Personally, I'd just change any link to use the wsl.exe command instead of ubuntu.exe (or ubuntu2004.exe). Assuming that Ubuntu is your default WSL distribution (found via wsl -l -v), then will have the same effect and just launch it. - Edit -- It's worthwhile to actually fix this.

  • From the Github reports, you can truly fix the issue by unregistering the Ubuntu distribution. Note that this is a destructive operation that will remove your existing Ubuntu distribution.

    Assuming that the distribution still runs, via the wsl command, it is possible to back it up before unregistering, then restore it afterwards.

    I would do this in two steps:

    • First, create a backup of the distribution via the wsl --export command. Exit the distribution, then go to PowerShell and:

      wsl -l -v
      # Change "Ubuntu-20.04" in the next line to match the distribution name in use
      wsl --export Ubuntu-20.04 ubuntu_backup.tar
      • Second, find the virtual drive for your Ubuntu WSL distribution. Start in File Explorer with:

        %userprofile%\AppData\Local\Packages

        Then find the CanonicalGroupLimited...Ubuntu (the name may vary.

        Inside that, find ..\LocalState\ext4.vhdx. Copy that file to a safe location.

      • With two different backups in place, it's time to unregister Ubuntu from WSL. Remember that this is a destructive operation:

        wsl -l -v # Change "Ubuntu-20.04" in the next line to match the distribution name in use
        wsl --unregister Ubuntu-20.04
      • Rerun the ubuntu2004.exe or ubuntu.exe (either from the command-line or the Start menu)

        Ubuntu will again run its installation and initial configuration (and it should now work with the "bad" version unregistered). While you can enter a username and password here, we're just going to throw this "installation" away anyway.

      • Exit the Ubuntu distribution

      • From PowerShell:

        wsl --terminate Ubuntu-20.04 # or Ubuntu
      • Copy the ext4.vhdx that you saved above back into %userprofile%\AppData\Local\CanonicalGroup...Ubuntu...\LocalState over the newly created one.

At that point, the ubuntu.exe or ubuntu2004.exe command should work once again (as well as from the Start menu).

11

One thing to add if you use Docker you will most likely also need to update your container images. You can rundocker-compose pullNow you will also need to run the following which will update the container images.docker-compose up --detachup command automatically recreates container on image or configuration change.

Try to run this code:wsl.exe -d Ubuntu20.04LTS in your CMD or Powershell. I ran it in the Terminal app

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like