Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'wsl --install' is not installing default distribution (Ubuntu) #1303

Closed
vvavrychuk opened this issue Oct 7, 2021 · 9 comments
Closed

'wsl --install' is not installing default distribution (Ubuntu) #1303

vvavrychuk opened this issue Oct 7, 2021 · 9 comments

Comments

@vvavrychuk
Copy link
Contributor

Page https://docs.microsoft.com/en-us/windows/wsl/install says that from Windows 10 version 2004 and higher (Build 19041 and higher) command wsl --install should install Ubuntu by default, but it is not the case for me

C:\Users\vvavr>wsl --install
Copyright (c) Microsoft Corporation. All rights reserved.

Usage: wsl.exe [Argument] [Options...] [CommandLine]

Arguments for running Linux binaries:

    If no command line is provided, wsl.exe launches the default shell.

    --exec, -e <CommandLine>
        Execute the specified command without using the default Linux shell.

    --
        Pass the remaining command line as is.

Options:
    --cd <Directory>
        Sets the specified directory as the current working directory.
        If ~ is used the Linux user's home path will be used. If the path begins
        with a / character, it will be interpreted as an absolute Linux path.
        Otherwise, the value must be an absolute Windows path.

    --distribution, -d <Distro>
        Run the specified distribution.

    --user, -u <UserName>
        Run as the specified user.

    --system
        Launches a shell for the system distribution.

Arguments for managing Windows Subsystem for Linux:

    --help
        Display usage information.

    --install [Options]
        Install additional Windows Subsystem for Linux distributions.
        For a list of valid distributions, use 'wsl --list --online'.

        Options:
            --distribution, -d [Argument]
                Downloads and installs a distribution by name.

                Arguments:
                    A valid distribution name (not case sensitive).

                Examples:
                    wsl --install -d Ubuntu
                    wsl --install --distribution Debian

    --set-default-version <Version>
        Changes the default install version for new distributions.

    --shutdown
        Immediately terminates all running distributions and the WSL 2
        lightweight utility virtual machine.

    --status
        Show the status of Windows Subsystem for Linux.

    --update [Options]
        If no options are specified, the WSL 2 kernel will be updated
        to the latest version.

        Options:
            --rollback
                Revert to the previous version of the WSL 2 kernel.

Arguments for managing distributions in Windows Subsystem for Linux:

    --export <Distro> <FileName>
        Exports the distribution to a tar file.
        The filename can be - for standard output.

    --import <Distro> <InstallLocation> <FileName> [Options]
        Imports the specified tar file as a new distribution.
        The filename can be - for standard input.

        Options:
            --version <Version>
                Specifies the version to use for the new distribution.

    --list, -l [Options]
        Lists distributions.

        Options:
            --all
                List all distributions, including distributions that are
                currently being installed or uninstalled.

            --running
                List only distributions that are currently running.

            --quiet, -q
                Only show distribution names.

            --verbose, -v
                Show detailed information about all distributions.

            --online, -o
                Displays a list of available distributions for install with 'wsl --install'.

    --set-default, -s <Distro>
        Sets the distribution as the default.

    --set-version <Distro> <Version>
        Changes the version of the specified distribution.

    --terminate, -t <Distro>
        Terminates the specified distribution.

    --unregister <Distro>
        Unregisters the distribution and deletes the root filesystem.

    --mount <Disk>
        Attaches and mounts a physical disk in all WSL2 distributions.

        Options:
            --bare
                Attach the disk to WSL2, but don't mount it.

            --type <Type>
                Filesystem to use when mounting a disk, if not specified defaults to ext4.

            --options <Options>
                Additional mount options.

            --partition <Index>
                Index of the partition to mount, if not specified defaults to the whole disk.

    --unmount [Disk]
        Unmounts and detaches a disk from all WSL2 distributions.
        Unmounts and detaches all disks if called without argument.

On the other hand, wsl --install -d Ubuntu works fine.

I have windows version dev (os build 21390.2025).


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

  • ID: 0cc9a77f-e6a1-a719-c337-7ff7506a1ac8
  • Version Independent ID: 7ed8fb81-5b8f-4d56-7b89-bf600ce6080a
  • Content: Install WSL
  • Content Source: WSL/install.md
  • Product: dev-environment
  • Technology: windows-subsystem-for-linux
  • GitHub Login: @craigloewen-msft
  • Microsoft Alias: crloewen
@mab0189
Copy link

mab0189 commented Oct 23, 2021

I had the same experience with version 21H1 (Build 19043.1288).

@SimpleSamples
Copy link

Thank you! I got the same using wsl --install and the workaround works for me too. This is with 20H2.

@slonopotamus
Copy link

slonopotamus commented Jan 9, 2022

On the other hand, wsl --install -d Ubuntu works fine.

No, it doesn't. Page says:

This command will enable the required optional components, download the latest Linux kernel, set WSL 2 as your default, and install a Linux distribution for you (Ubuntu by default, see below to change this).

wsl --install -d Ubuntu does neither of those three items on Windows 20H2.

UPDATE: The situaton is a bit trickier. It is true that wsl --install -d Ubuntu will do all listed actions on a clean OS. But if you have already installed WSL1 in the past (via Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux in elevated PowerShell, for example), then wsl --install -d Ubuntu won't install WSL2, won't enable WSL2 by default and won't download WSL2 kernel.

@slonopotamus
Copy link

slonopotamus commented Jan 12, 2022

Okay, things are even more complicated.

With clean Windows 20H2, no-arg wsl --install does work from an elevated console. But if you have WSL1 (Microsoft-Windows-Subsystem-Linux feature) or WSL2 (VirtualMachinePlatform feature) installed, no-arg wsl --install no longer works.

Note that wsl --install also works if you uninstall WSL1+2 and then reboot.

@slonopotamus
Copy link

slonopotamus commented Jan 12, 2022

I'd score quality of implementation of this feature as -2 on 0-10 scale. @microsoft please, hire better programmers and QA.

@crramirez
Copy link
Contributor

@slonopotamus, I still don't understand your point. wsl --install with no arguments is made to install WSL. If you already have WSL installed, you don't need no-arg wsl --install; you need only to install distros. If you want to update the kernel run wsl --update

wsl --install as you are requesting would be very difficult to implement and error-prone. For example, if you already have WSL1 installed and run wsl --install, why it would assume that you want to install WSL2. If you have WSL2, why does running wsl --install would make WSL2 by default, etc.

"@microsoft please, hire better programmers and QA." it is not a bug; the command is made on purpose in that way.

@crramirez
Copy link
Contributor

Also check this comment for clarifications: #1408 (comment)

@slonopotamus
Copy link

slonopotamus commented Jan 14, 2022

If I don't have network connection, wsl --install installs VirtualMachinePlatform and then... Stops. Now you have half-installed WSL2, without kernel and without distro. And you can't wsl --install anymore, because (remember?) wsl --install only works when you don't have WSL at all. And now user needs to download kernel MSI manually. And he goes to this bugtracker and asks "wtf, why I need to do steps for older distros when I have the latest 21H2?"

if you already have WSL1 installed and run wsl --install, why it would assume that you want to install WSL2

It doesn't need to assume anything. Don't try to outsmart the user. I'll quote again:

This command will enable the required optional components, download the latest Linux kernel, set WSL 2 as your default, and install a Linux distribution for you (Ubuntu by default, see below to change this).

So, your docs clearly indicate that no-arg wsl --install is a way to get WSL2.

If you already have WSL installed, you don't need no-arg wsl --install; you need only to install distros.

Wrong. If I already have WSL1 installed, I may still want to install WSL2.

@craigloewen-msft
Copy link
Collaborator

As others have said this is because WSL is already installed! We put in a note on the main page to make sure that this is seen by other users, and have fixed this error code in later versions of the product.
#1433

Thanks for filing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants