Skip to content

Commit a809ce4

Browse files
authored
Merge pull request #4 from simo787c/fix/install-ps1-arch
[fix] fix install.ps1 arch detection for PowerShell 5.x
2 parents 89ce30c + f809270 commit a809ce4

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

install.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ function Write-Info($msg) { Write-Host "sonar " -ForegroundColor Cyan -NoNewline
1010
function Write-Ok($msg) { Write-Host " OK " -ForegroundColor Green -NoNewline; Write-Host $msg }
1111
function Write-Err($msg) { Write-Host " ERR " -ForegroundColor Red -NoNewline; Write-Host $msg; exit 1 }
1212

13-
# Detect architecture
14-
$Arch = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
15-
"X64" { "amd64" }
16-
"Arm64" { "arm64" }
13+
# Detect architecture ($env:PROCESSOR_ARCHITECTURE works on PowerShell 5.x;
14+
# RuntimeInformation is unavailable there and crashes the script)
15+
$Arch = switch ($env:PROCESSOR_ARCHITECTURE) {
16+
"AMD64" { "amd64" }
17+
"ARM64" { "arm64" }
1718
default { Write-Err "Unsupported architecture: $_" }
1819
}
1920

0 commit comments

Comments
 (0)