From 10a128a34a446f80d8900a141706558789973859 Mon Sep 17 00:00:00 2001 From: Aurelio <19254254+Aureliolo@users.noreply.github.com> Date: Tue, 17 Mar 2026 23:14:50 +0100 Subject: [PATCH 1/3] fix(cli): add fallback arch detection in PowerShell installer RuntimeInformation::OSArchitecture returns $null on some Windows systems with older .NET runtimes, causing the installer to fail with "Unsupported architecture:". Fall back to $env:PROCESSOR_ARCHITECTURE which is available on all Windows versions. Closes #521 --- cli/scripts/install.ps1 | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/cli/scripts/install.ps1 b/cli/scripts/install.ps1 index 42694997d4..c3f5f86cd9 100644 --- a/cli/scripts/install.ps1 +++ b/cli/scripts/install.ps1 @@ -30,12 +30,30 @@ if ($Version -notmatch '^v\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$') { Write-Host "Installing SynthOrg CLI $Version..." # --- Detect architecture --- +# Primary: .NET RuntimeInformation (PowerShell 5.1+ with .NET 4.7.1+). +# Fallback: PROCESSOR_ARCHITECTURE env var (always available on Windows). +# The RuntimeInformation API can return $null on older .NET runtimes or +# certain system configurations (see #521). -$OsArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -$WinArch = switch ($OsArch) { - ([System.Runtime.InteropServices.Architecture]::X64) { "amd64" } - ([System.Runtime.InteropServices.Architecture]::Arm64) { "arm64" } - default { Write-Error "Unsupported architecture: $OsArch"; exit 1 } +$OsArch = $null +try { + $OsArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture +} catch { + # Type not available — fall through to env var detection. +} + +if ($null -ne $OsArch) { + $WinArch = switch ($OsArch) { + ([System.Runtime.InteropServices.Architecture]::X64) { "amd64" } + ([System.Runtime.InteropServices.Architecture]::Arm64) { "arm64" } + default { Write-Error "Unsupported architecture: $OsArch"; exit 1 } + } +} else { + $WinArch = switch ($env:PROCESSOR_ARCHITECTURE) { + "AMD64" { "amd64" } + "ARM64" { "arm64" } + default { Write-Error "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE"; exit 1 } + } } # --- Download --- From d672b251791ef089b99f31a26df432e5e9d0dee3 Mon Sep 17 00:00:00 2001 From: Aurelio <19254254+Aureliolo@users.noreply.github.com> Date: Tue, 17 Mar 2026 23:33:29 +0100 Subject: [PATCH 2/3] fix: add Write-Verbose to catch block for observability Addresses PSScriptAnalyzer PSAvoidUsingEmptyCatchBlock warning. Users running with -Verbose can now see why the fallback was used. --- cli/scripts/install.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/scripts/install.ps1 b/cli/scripts/install.ps1 index c3f5f86cd9..060e467169 100644 --- a/cli/scripts/install.ps1 +++ b/cli/scripts/install.ps1 @@ -40,6 +40,7 @@ try { $OsArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture } catch { # Type not available — fall through to env var detection. + Write-Verbose "RuntimeInformation unavailable; using PROCESSOR_ARCHITECTURE fallback." } if ($null -ne $OsArch) { From 92399a77e48866f835d939d80559ff1f59414d80 Mon Sep 17 00:00:00 2001 From: Aurelio <19254254+Aureliolo@users.noreply.github.com> Date: Tue, 17 Mar 2026 23:43:18 +0100 Subject: [PATCH 3/3] fix: handle WOW64 arch detection and remove non-ASCII chars - Check PROCESSOR_ARCHITEW6432 before PROCESSOR_ARCHITECTURE to get the real OS architecture when running 32-bit PowerShell on 64-bit Windows (WOW64 scenario) - Replace em-dash with ASCII dash to avoid PSUseBOMForUnicodeEncodedFile warning and potential encoding issues on Windows PowerShell 5.1 --- cli/scripts/install.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/scripts/install.ps1 b/cli/scripts/install.ps1 index 060e467169..d6b59d2f04 100644 --- a/cli/scripts/install.ps1 +++ b/cli/scripts/install.ps1 @@ -39,7 +39,7 @@ $OsArch = $null try { $OsArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture } catch { - # Type not available — fall through to env var detection. + # Type not available - fall through to env var detection. Write-Verbose "RuntimeInformation unavailable; using PROCESSOR_ARCHITECTURE fallback." } @@ -50,10 +50,13 @@ if ($null -ne $OsArch) { default { Write-Error "Unsupported architecture: $OsArch"; exit 1 } } } else { - $WinArch = switch ($env:PROCESSOR_ARCHITECTURE) { + # PROCESSOR_ARCHITEW6432 is set when running 32-bit PowerShell on 64-bit + # Windows (WOW64). It contains the real OS architecture. + $ArchEnv = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE } + $WinArch = switch ($ArchEnv) { "AMD64" { "amd64" } "ARM64" { "arm64" } - default { Write-Error "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE"; exit 1 } + default { Write-Error "Unsupported architecture: $ArchEnv"; exit 1 } } }