`wsl --install --location` downloads distribution before validating target directory existence
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:
- Validate that the specified drive and target path exist (or can be created) during initial command-line argument parsing.
- 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.
Source: microsoft/WSL