0

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.

4
  • 2
    Is WSL2 an absolute requirement? Would a virtual machine be a viable option?
    – matigo
    Jun 25 at 23:33
  • I suppose I COULD use VirtualBox if I had to. Originally, I started using wsl (not 2) because its performance with Docker was so much better (at least, for small things where startup time accounted for much or most of the total time). Once wsl (and implicitly, Hyper-V) was enabled, VirtualBox became completely unusable. Later, when I got back into building AOSP, I graduated to wsl2 so I could run xfce and DDD via VcXsrv. I eventually got the latest version of VirtualBox to not die upon booting Linux with HyperV active, but the performance was abysmal.
    – Bitbang3r
    Jun 26 at 3:07
  • Now that I can't meaningfully use wsl(2) at all until I either reinstall Windows or Microsoft gets its act together and comes up with a proper way to fix a broken Store installation, I suppose I might as well disable wsl and HyperV so VirtualBox will at least work properly again. Sigh.
    – Bitbang3r
    Jun 26 at 3:26
  • It sounds like you've done your research, and I know you say you aren't looking for help with fixing the Store, but you might want to try asking about that over on Super User. Would a "Repair" work for Windows instead of a full reinstallation? Even during a full install, there's still an option to keep user files and apps. Jun 27 at 15:28
0

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.

2
  • Hi, the steps worked well. when trying to login with "wsl -u username" it gives error "-sh: 6: export: (x86)/Common: bad variable name"
    – neogeomat
    Aug 5 at 13:57
  • @neogeomat And that's without doing anything else? I just saw someone else with that error recently. I'm fairly sure the problem is with a script that is being run through sh (not bash) that isn't properly quoting the "$PATH" variable. See this answer for more detailed discussion. Aug 5 at 14:28
-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..

3
  • Welcome to Ask Ubuntu. There are likely a few reasons why you are receiving downvotes. First, your original "answer" (the current first paragraph) is just a link to try to help solve the problem that the original poster said they were not trying to solve. Since that is not related to the actual question, it really deserves to be a comment (as I did on that topic under the main question). I realize that, as a new user, you don't have the reputation to post comments, and that's by design. Once you ask or answer questions responsibly, you will gain this privilege. Sep 22 at 15:32
  • Second, link-only answers are highly frowned on here (and likely an additional cause of downvotes). At least summarize the link you provided, but as you said, it's mostly a duplicate of what I posted (although there is some usefulness to the differences in that Super User answer). And, as a side note, no, I did not copy that answer -- I came up with my answer through actually understanding the process, and I made sure to test each step of my answer to make sure it applied to this particular question properly. Even so, in retrospect, my answer could be simplified. Sep 22 at 15:34
  • Hi, thanks for your comments which I may accept more or less, also attributing this to my very beginner level. Yet I don't know why straight solutions to obvious things other miss can be down-voted and lenghty personal contributions do excel above straight vendor information on topic (delivered later). Anyhow, I wanted to share something I had fresh experience with, just as giving credit to this otherwise awesome world of S.E. network I got inspired so many times to date. Respect to your skills and depth, I won't get there as simply life happens. Have a good time!
    – PeterG
    Sep 22 at 19:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.