Skip to content

fix(install): convert OSArchitecture enum to string before switch comparison#111

Merged
largeoliu merged 1 commit into
masterfrom
fix/install-ps51-osarchitecture-enum
May 10, 2026
Merged

fix(install): convert OSArchitecture enum to string before switch comparison#111
largeoliu merged 1 commit into
masterfrom
fix/install-ps51-osarchitecture-enum

Conversation

@largeoliu
Copy link
Copy Markdown
Owner

Summary

Fix install.ps1 failing with [ERROR] Unsupported architecture on Windows PowerShell 5.1.

Root Cause

In PowerShell 5.1, System.Runtime.InteropServices.RuntimeInformation.OSArchitecture returns a System.Runtime.InteropServices.Architecture enum value (e.g. X64), not a string. When the switch statement compared the enum directly against string literals "X64" and "Arm64", the comparison failed silently, falling through to the default branch which throws the error.

Fix

Convert the enum to string via .ToString() before the switch comparison:

$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
$archStr = $arch.ToString()
switch ($archStr) {
    "X64"   { return "amd64" }
    "Arm64" { return "arm64" }
    ...
}

Verification

  • Locally tested with powershell -File install.ps1 -SkipPathUpdate -Version "v0.5.0" — installed successfully
  • All 3 code paths covered: enum-to-string match, env var fallback, and unsupported-arch error

…parison

PowerShell 5.1 returns Architecture enum instead of string for
System.Runtime.InteropServices.RuntimeInformation.OSArchitecture,
causing switch comparison to fail with 'Unsupported architecture' error.
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@largeoliu largeoliu merged commit 73c310c into master May 10, 2026
17 checks passed
@largeoliu largeoliu deleted the fix/install-ps51-osarchitecture-enum branch May 10, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants