1

This question was originally posted on Ask Ubuntu here, but since it turns out to be common to non-Ubuntu WSL distributions (and even non-WSL apps), I was asked to recreate it here on Super User. The original will be closed, but it's still there for reference for now. Please direct all comments and answers to this Super User question.

After installing an app from the Microsoft Store on Windows 10, it initially works. However, when I restart Windows, the app is gone. It does not appear in the Start Menu any longer. What could be causing this?

I originally noticed the problem when installing Ubuntu 20.04 using WSL2 from the Microsoft Store. It worked fine when the system was running, but on restart it was uninstalled or disappeared. I could reinstall it again, and it would work, but each reboot would cause it to disappear again.

From the comments, we determined that:

  • WSL itself was still installed. The wsl -l -v command worked, but showed:

    Windows Subsystem for Linux has no installed distributions
    

    Before rebooting, however, it correctly showed Ubuntu 20.04 at version 2.

  • Also, the Store packages seem to be uninstalled entirely.

    After installing Ubuntu, running Get-ChildItem -Recurse 'C:\Program Files\WindowsApps\' | Where-Object {$_.Name -eq 'install.tar.gz' } | ForEach-Object { $_.Directory.BaseName } in PowerShell results in:

    ConicalGroupLimited.Ubuntu20.04onWindows_2004_2021.825.0_x64__79rhkplfndgsc
    

    But after rebooting, it shows no results.

  • The same problem occurs with Ubuntu 18.04.

  • And then we found that the same problem occurs even with non-WSL apps installed from the Store.

NotTheDr01ds
  • 28,025

1 Answers1

0

Wondering if you ever got this working, but proposing a possible solution for WSL (and only WSL) for others that might run into it. Of course, it's best if you can solve the core issue so that Apps don't get uninstalled after rebooting, but if you really need WSL without the App, you can get by with this method.

If the installed Microsoft Store apps are being reset, but WSL itself is still installed (which we verified via wsl -l -v), then you should be able to "disconnect" the Ubuntu WSL installation from the Store installation.

Note: This assumes that files in your Windows Documents directory are not being reset.

To do this:

  • Install "Ubuntu" from the Microsoft Store. You could also use one of the "versioned" releases such as "Ubuntu 20.04", but note that you'll need to adjust the names in the commands below accordingly.

  • Launch it for the first time so that it asks you to create a username and password.

  • Exit it

  • Start PowerShell

  • wsl -l -v to show the installed distributions. There should be just the one Ubuntu.

  • Also from PowerShell:

    wsl --shutdown
    cd ~\Documents
    mkdir wsl\instances\MyUbuntu
    mkdir wsl\images
    wsl --export Ubuntu wsl\images\ubuntu.tar
    wsl --import MyUbuntu wsl\instances\MyUbuntu wsl\images\ubuntu.tar --version 2
    wsl --set-default MyUbuntu
    wsl -l -v # should show both Ubuntu and MyUbuntu in the list
    wsl
    
  • You should now be in your MyUbuntu instance. Confirm this with echo $WSL_DISTRO_NAME.

  • You should also be root, since WSL doesn't automatically set the default user for --imported instances. To change this:

    sudo -e /etc/wsl.conf
    
  • Add the following to that file:

    [user]
    default=yourWSLusername
    

    This should be set to the username you created during the initial Ubuntu installation above.

  • Exit WSL (back to PowerShell) and:

    wsl --terminate MyUbuntu
    

That should be it. You should now have a MyUbuntu WSL distribution/instance installed that will survive even if the Ubuntu app gets uninstalled after reboot.

To run it, use the wsl command instead of the ubuntu command. You can add a shortcut in your Start menu to wsl if you'd like.

NotTheDr01ds
  • 28,025