2

Is there any way to install 20.04 for use with wsl2 that doesn't depend upon Microsoft Store (or Add-AppxPackage) working?

Why: Microsoft Store and Add-AppxPackage are broken on my computer, attempts to fix them were unsuccessful, and Microsoft's only solution is "reinstall Windows" because there's no way to just regenerate it, or to uninstall and reinstall Store by itself. Others have already discovered that Add-AppxPackage isn't a loophole to getting around a broken Microsoft Store.


Incidentally, I already tried to download it by running:

Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing
Add-AppxPackage .\Ubuntu.appx

Unfortunately, here's the error message I got:

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates, dependency or conflict
validation.
Deployment Add operation with target volume C: on Package
CanonicalGroupLimited.Ubuntu20.04onWindows_2004.2020.424.0_x64__79rhkp1fndgsc from:  (Ubuntu.appx)  failed with error
0x80073CF3. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.
NOTE: For additional information, look for [ActivityId] 014ee586-6a11-0004-ce43-5001116ad701 in the Event Log or use
the command line Get-AppPackageLog -ActivityID 014ee586-6a11-0004-ce43-5001116ad701
At line:1 char:1
+ Add-AppxPackage .\Ubuntu.appx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (D:\Downloads\Ubuntu.appx:String) [Add-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

If you dig through the error messages in EventViewer, they ultimately come down to "an XML file needed by Microsoft Store was somehow deleted, and there's no way to get it back without reinstalling Store by reinstalling Windows" :-(

Anyway, I don't expect anyone here to help with diagnosing Microsoft Store, I'm just hoping that there's some alternate way to install Ubuntu 20.04 for WSL2 that doesn't need Windows Store to work.

Bitbang3r
  • 121

2 Answers2

2

As long as you already have WSL installed (which doesn't rely on the Store anyway, so that shouldn't be a problem), you can use the wsl --import subcommand to get the Ubuntu distribution "side-loaded".

The package that you already downloaded contains the file you need, but for the sake of streamlining the directions, I'm going to have you download it again. You can tweak this recipe if you'd like, of course:

  • First, choose a location for your WSL files. For example:

    cd $env:USERPROFILE
    mkdir -p wsl\instances\Ubuntu20_04
    mkdir wsl\images
    cd wsl
    
  • Download the Appx package manually into that wsl directory, either through the proper direct link found here or, in your case, via:

    # Assuming we are still in the `wsl` directory created above
    Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing 
    
  • The resulting file is actually just a renamed .zip file. Extract it in PowerShell and move the install.tar.gz to the images directory created above:

    # Still in the `wsl` directory
    Expand-Archive Ubuntu.appx
    mv Ubuntu\install.tar.gz images\
    Remove-Item -Recurse Ubuntu
    
  • You'll need to extract the install.tar.gz file to install.tar. Neither PowerShell nor Windows have a built-in feature to do this, so I'll leave that to your preference. I'm guessing you already have something like 7-zip installed already.

  • Rename the images\install.tar to images\Ubuntu20_04.tar. This isn't strictly necessary, but I like to keep the "pristine" image around in case you want to install additional instances. WSL is great for spinning up "throwaway" instances where you can try out something potentially destructive without fear of corrupting your main instance.

  • Still from within the wsl directory:

    wsl --import Ubuntu20.04 instances\Ubuntu20_04 images\Ubuntu20_04.tar --version 2
    wsl --set-default Ubuntu20.04 # Optional, and perhaps unnecessary if this is the first distribution installed
    wsl -u root useradd --create-home --user-group --groups  adm,dialout,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev --password "encryptedPassword" username
    

    ... Of course, adjust username to be your username. See here for how to create the encrypted password.

    To the best of my knowledge, this will create a user the same way that the default user is created by the Microsoft Store installation of Ubuntu 20.04.

  • Start WSL Ubuntu as root:

    wsl -u root
    
  • To set the default user that runs when the instance starts, create a /etc/wsl.conf with the following contents:

    [user]
    default=username
    

    ... substituting your username, of course.

  • Exit back to PowerShell

  • Shutdown the instance to allow it to come back up and read the wsl.conf:

    wsl --terminate Ubuntu20.04
    

That should be it. Running wsl should start Ubuntu 20.04 running under your user ID.

I haven't had a chance to test every step in here end-to-end, but this is a combination of things I've done in the past and other answers I've provided. I believe I've got all the pieces put together that you need, but if you run into issues, let me know, and I'll review and tweak it.

NotTheDr01ds
  • 22,082
-3

To solve a problem that seemed to require reinstallation of Windows, I made use of a so called "in-place upgrade" capability of Windows installer that reinstalls keeping all your files and apps! This might help you. See this tutorial for example, for details.

Today I even managed to find this ultimate explanation to your main question, if not been copied-by other guy here, as this one is older post: https://superuser.com/questions/1271682/is-there-a-way-of-installing-ubuntu-windows-subsystem-for-linux-on-win10-v170 As last one, even MS documents this all: https://docs.microsoft.com/en-us/windows/wsl/install-manual

Hope my post will decrease in number of downvotes now..

PeterG
  • 1