podman icon indicating copy to clipboard operation
podman copied to clipboard

Automatic installation of WSL fails

Open l0rd opened this issue 8 months ago • 2 comments

Issue Description

If WSL isn't installed, and a user tries to run podman machine init on Windows, Podman tries to install WSL automatically. This flow is currently broken.

Steps to reproduce the issue

Steps to reproduce the issue

  1. Disable the Windows feature VirtualMachinePlatform and reboot
  2. (until #25522 get merged) Build podman from PR #25522
  3. Run podman machine init

Describe the results you received

When machine init is run from an Admin terminal, the command fails with the error Error: could not enable Virtual Machine Feature: command dism [/online /enable-feature /featurename:VirtualMachinePlatform /all /norestart] failed: exit status 3010.

When machine init is run from a non-Admin terminal, the command fails because podman machine init is re-executed with elevated privileges and the hidden parameter --reexec. It fails when it tries to recreate the system connection with the same name (the system connection was already created before the WSL check).

Describe the results you expected

WSL should be enabled successfully

podman info output

OS: windows/amd64
provider: wsl
version: 5.5.0-dev

Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman socket: Get "http://d/v5.5.0/libpod/_ping": dial unix /run/podman/podman.sock: connect: A socket operation encountered a dead network.

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

Additional environment details

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

l0rd avatar Mar 10 '25 19:03 l0rd

I've been facing this issue since yesterday. The documentation clearly states that WSL will be setup automatically as a part of the podman machine init.

  1. First, the init process fails immediately if WSL is outdated/stock version is available. I had to manually update wsl to move to the next step.
  2. WSL's installation process itself is supposed to auto-enable some Windows Features, which usually works fine. Podman straight away fails due to features being unavailable, we have to do that manually.

....it seems like complete manual installation of WSL is still required for podman to be initiated successfully.

Kindly let me know if I am missing something in my setup, or if I am going wrong somewhere :)

farhan-ct avatar Mar 14 '25 06:03 farhan-ct

@farhan-ct, this issue makes only sense if this PR gets merged. Without that, the machine init command always assumes that WSL is installed and the required Windows feature is enabled. Thank you for the feedback; I missed that the doc mentioned it, and we may need to remove it if we can't fix it in the short term.

l0rd avatar Mar 20 '25 10:03 l0rd

It would also be helpful to catch error code 3010 from dism and just prompt the user to restart.

Had this error come up multiple times running podman machine init when it tried to automatically enable WSL2 - took me a while to figure out that error code 3010 just means "hey, that windows feature is installed, but I need a restart".

elemental-mind avatar Apr 09 '25 10:04 elemental-mind