From e828cb1988af06cf7529d022e6af0ef431d3da8c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 27 Aug 2024 04:26:25 +0200 Subject: [PATCH] Force the use of the managed distribution --- scripts/Common/Scripts/Operations.ps1 | 2 +- scripts/Windows/Scripts/WSL.ps1 | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/Common/Scripts/Operations.ps1 b/scripts/Common/Scripts/Operations.ps1 index be0991cc..e8c71856 100644 --- a/scripts/Common/Scripts/Operations.ps1 +++ b/scripts/Common/Scripts/Operations.ps1 @@ -173,7 +173,7 @@ $null = New-Module { return; } - if (-not (Test-WslDistributions)) { + if (-not (Test-WslDistribution)) { if (-not (Test-Path (Get-WslDistributionDisk))) { Install-WslDistribution; } diff --git a/scripts/Windows/Scripts/WSL.ps1 b/scripts/Windows/Scripts/WSL.ps1 index 57b5125a..96350f6e 100644 --- a/scripts/Windows/Scripts/WSL.ps1 +++ b/scripts/Windows/Scripts/WSL.ps1 @@ -40,6 +40,14 @@ function Test-WslDistributions { & { $null = wsl -l; $?; }; } +<# + .SYNOPSIS + Checks whether the managed distribution is installed. +#> +function Test-WslDistribution { + & { $null = wsl -d (Get-WslDistributionName) -e true; $?; }; +} + <# .SYNOPSIS Installs `wsl` on the system.