Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(windows): reject unsupported builds before WSL setup (#8284)

Mike Bradley8544312e47de
diff --git a/ods/installers/windows/lib/wsl-portal-setup.ps1 b/ods/installers/windows/lib/wsl-portal-setup.ps1
index 29a37534e..73b19f329 100644
--- a/ods/installers/windows/lib/wsl-portal-setup.ps1
+++ b/ods/installers/windows/lib/wsl-portal-setup.ps1
@@ -3,6 +3,18 @@
. (Join-Path $PSScriptRoot 'wsl-portal-amd.ps1')
. (Join-Path $PSScriptRoot 'wsl-portal-spark.ps1')
+function Get-ODSPortalWindowsBuild {
+ return [Environment]::OSVersion.Version.Build
+}
+
+function Assert-ODSPortalWindowsBuild {
+ # Match the supported installer minimum in enable-wsl-features.ps1.
+ $build = Get-ODSPortalWindowsBuild
+ if ($build -lt 19041) {
+ throw "This version of ODS requires Windows build 19041 or newer. This computer reports build $build. Update Windows, then run the installer again."
+ }
+}
+
function Write-ODSPortalStage([int]$Step, [string]$Title, [string]$Detail) {
Write-Host ''
$style = @{}
@@ -307,6 +319,7 @@ function Install-ODSPortalDockerBeforeRestart([bool]$NonInteractive) {
function Initialize-ODSPortalWindowsFoundation([System.Collections.IDictionary]$Options, [string]$InstallerRoot, [bool]$NonInteractive) {
# Returns $null when WSL is ready, otherwise the exit code to stop with.
+ Assert-ODSPortalWindowsBuild
$present = [bool](Get-Command wsl.exe -ErrorAction SilentlyContinue)
$ready = $present -and ((Invoke-ODSPortalWsl -Arguments @('--status')).Code -eq 0)
Assert-ODSPortalHostCapacity $ready
diff --git a/ods/installers/windows/phases/01-preflight.ps1 b/ods/installers/windows/phases/01-preflight.ps1
index 31fdfcd95..ef9e1bfe5 100644
--- a/ods/installers/windows/phases/01-preflight.ps1
+++ b/ods/installers/windows/phases/01-preflight.ps1
@@ -56,11 +56,11 @@ if (-not $_psVer.Sufficient) {
Write-AISuccess "PowerShell $($_psVer.Version) OK"
# ── Windows version ──────────────────────────────────────────────────────────
-# WSL2 requires Windows 10 build 18362 (version 1903) or later.
+# The supported ODS automated installer requires Windows build 19041 or newer.
try {
$_build = [System.Environment]::OSVersion.Version.Build
- if ($_build -lt 18362) {
- Write-AIError "Windows 10 build 18362 (version 1903) or later is required for WSL2."
+ if ($_build -lt 19041) {
+ Write-AIError "This version of ODS requires Windows build 19041 or newer."
Write-AI " Your build: $_build. Update Windows and re-run."
throw "ODS_INSTALL_ABORTED"
}
diff --git a/ods/tests/contracts/test-windows-portal-setup.ps1 b/ods/tests/contracts/test-windows-portal-setup.ps1
index f7b49d3b0..aac55d11c 100644
--- a/ods/tests/contracts/test-windows-portal-setup.ps1
+++ b/ods/tests/contracts/test-windows-portal-setup.ps1
@@ -84,6 +84,7 @@ function Reset-Scenario {
$script:calls = [Collections.Generic.List[string]]::new()
$script:prompts = [Collections.Generic.List[string]]::new()
$script:scenario = 'ready'
+ $script:windowsBuild = 19045
$script:delegateCode = 0
$script:featureCode = 0
$script:allowPreparation = $true
@@ -120,6 +121,7 @@ function Reset-Scenario {
function Test-ODSPortalVirtualization { $script:calls.Add('virt-check'); return $script:virtualization }
function Test-ODSSparkWindowsArm64 { $script:calls.Add('arm64-check'); return $script:arm64 }
function Get-ODSPortalFreeSystemGB { return $script:freeGB }
+function Get-ODSPortalWindowsBuild { return $script:windowsBuild }
function Get-ODSPortalWslRegistrations { return $script:wslRegistrations }
function Get-ODSPortalDockerDesktop { return [pscustomobject]@{ Installed=$script:dockerInstalled; Exe='docker-desktop.exe'; Cli='docker.exe' } }
function Install-ODSPortalDockerDesktop {
@@ -270,6 +272,32 @@ try {
Check ((Invoke-ODSPortalSetup @{} 'unused') -eq 0) 'ready host without -All delegates successfully'
Check ($script:capturedArguments[-1] -ceq '--pixel' -and $script:capturedArguments -notcontains '--no-hermes') 'Linux flags leave --no-hermes out, so a rerun keeps the installed selection'
Check ((@($script:capturedNewInstallation) -join ' ') -ceq '--no-hermes') 'Hermes is turned off only through the new-installation flag'
+ # Reject old Windows before WSL probes, prompts, elevation or installs,
+ # whether WSL is absent, unprepared, or already running.
+ foreach ($build in @(16299, 18362, 19040)) {
+ foreach ($nonInteractive in @($false, $true)) {
+ foreach ($wslMode in @('no-wsl', 'features', 'ready')) {
+ Reset-Scenario
+ $script:windowsBuild = $build
+ $script:scenario = $wslMode
+ $message = ''
+ try { $null = Invoke-ODSPortalSetup @{NonInteractive=$nonInteractive} 'unused' } catch { $message = $_.Exception.Message }
+ Check ($message -match 'requires Windows build 19041' -and $message -match "reports build $build" -and $message -match 'Update Windows') "build $build ($wslMode, nonInteractive=$nonInteractive) reports the requirement and remedy"
+ Check ($script:calls.Count -eq 0) "build $build ($wslMode, nonInteractive=$nonInteractive) stops before all downstream calls"
+ }
+ }
+ }
+ foreach ($build in @(19041, 19045, 22631)) {
+ Reset-Scenario
+ $script:windowsBuild = $build
+ Check ((Invoke-ODSPortalSetup @{} 'unused') -eq 0) "supported build $build keeps the ready-host flow"
+ Check ($script:calls.Contains('install:Ubuntu-24.04')) "supported build $build reaches the Linux installer"
+ }
+ Reset-Scenario
+ $script:windowsBuild = 19041
+ $script:scenario = 'no-wsl'
+ Check ((Invoke-ODSPortalSetup @{} 'unused') -eq 3010) 'supported build 19041 keeps the missing-WSL feature flow'
+ Check ($script:calls.Contains('features') -and $script:calls.Contains('resume')) 'supported build 19041 still activates features and schedules resume'
Reset-Scenario
$null = Invoke-ODSPortalSetup @{NoHermes=$true} 'unused'
Check ($script:capturedArguments -contains '--no-hermes') '-NoHermes turns Hermes off on a rerun too'