0

I'm trying to get Ubuntu 20.04 working with WSL2 on Windows 10 Home (10.0.19041 Build 19041) and so set the version to v2 for use with Docker Desktop.

I've set wsl --set-default-version 2 prior to installing Ubuntu 20.04 LTS from the Windows Store.

In the Ubuntu system (via Start Menu) I see:

$ wsl.exe -l -v
  NAME                   STATE           VERSION
* docker-desktop         Stopped         2
  Ubuntu-20.04           Running         1
  docker-desktop-data    Stopped         2

However, on the Windows host in PowerShell I do not see the Ubuntu distribution:

> wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop         Stopped         2
  docker-desktop-data    Stopped         2

Why is the distro missing when running the command from the Windows host?

(Secondarily: I'm unsure why the Ubuntu is set to v1 when I've set the default install to be v2!)

1
  • 1
    Oh, by the way, that might also explain why the version was different. If you did a wsl --set-default-version 2 in PowerShell, that was likely also changing the registry settings for that Admin user. Now that you have it running as your user, try running the wsl --set-default-version 2 again, then either install a different distro or wsl --export and wsl --import the existing one to make sure it took effect. Also, of course, you can change the existing one with wsl --set-version Ubuntu-20.04 2, although I still recommend a backup first with wsl --export. Commented May 12, 2021 at 16:52

1 Answer 1

1

In this case, as we confirmed in the comments, the problem turned out to be that PowerShell was being run in an elevated Admin session, so the wsl -l -v in PowerShell was retrieving (via registry entries) a different set of WSL instances that that from the (non-elevated user's) Start Menu.

For those that might run across this in the future, you can determine the Windows user for each instance and compare the two:

  • In "plain" PowerShell, run Write-Host ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)

  • In the WSl instance which was run from the Start Menu, run powershell.exe -c "Write-Host ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)". That's going to run a PowerShell subshell within the WSL instance to determine the user for the process.

It might also be useful to check the registry entries that WSL is using:

  • PowerShell: Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse
  • WSL: powershell.exe -c "Get-ChildItem 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss' -Recurse"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .