Skip to content

wsl --install --location downloads distribution before validating target directory existence #41625

Description

Is your feature request related to a problem? Please describe.
When installing a Linux distribution with a custom location using wsl --install <Distro> --location <Path>, WSL downloads the entire distribution image first. If the target directory specified in --location does not exist (which is my case) or parent path validation fails, the command terminates with an error only after the download completes.

This leads to poor UX, unnecessary wait times, and wasted bandwidth—especially on metered/slower network connections.

Describe the solution you'd like
Implement a pre-flight validation check on the --location path prior to initiating the distribution payload download.

Specifically:

  1. Validate that the specified drive and target path exist (or can be created) during initial command-line argument parsing.
  2. If the path does not exist, either create the target directory automatically or exit early with a clear error message (e.g., Error: Target directory 'D:\WSL\Ubuntu' does not exist.) before triggering the download step.

Describe alternatives you've considered
Allowing the download to proceed and creating the directory retroactively at the end of the pipeline, which remains vulnerable to path/permission failures after network time has already been consumed.

Additional context
Example reproduction (in my case, I don't have D:):

wsl --install Ubuntu --location D:\WSL\Ubuntu

Current flow: Download starts -> 100% complete -> Error: Directory does not exist.

Expected flow: Path validation check -> Error / Auto-create directory -> Download starts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions