Skip to content

fix(install): resolve Windows arch from env, not OSArchitecture#276

Merged
BlackHole1 merged 2 commits into
mainfrom
fix-win-install
Jun 9, 2026
Merged

fix(install): resolve Windows arch from env, not OSArchitecture#276
BlackHole1 merged 2 commits into
mainfrom
fix-win-install

Conversation

@BlackHole1

Copy link
Copy Markdown
Member

The previous code read [RuntimeInformation]::OSArchitecture, which can be absent on the type PowerShell resolves in Windows PowerShell 5.1: a shadowing assembly such as PSReadLine may define its own RuntimeInformation without that property. Under Set-StrictMode the missing-property read becomes a terminating PropertyNotFoundStrict error, so irm https://cli.oomol.com/install.ps1 | iex fails.

Detect the architecture from PROCESSOR_ARCHITEW6432 (falling back to PROCESSOR_ARCHITECTURE) instead. These work on every PowerShell version and report the true host architecture, including the WOW64 case where the inbox 32-bit PowerShell 5.1 on ARM64 resolves to arm64. The switch gains an amd64 case because that is the token PROCESSOR_ARCHITECTURE reports on x64 Windows.

Verified on real Windows PowerShell 5.1 and PowerShell 7.6.

The previous code read [RuntimeInformation]::OSArchitecture, which
can be absent on the type PowerShell resolves in Windows PowerShell
5.1: a shadowing assembly such as PSReadLine may define its own
RuntimeInformation without that property. Under Set-StrictMode the
missing-property read becomes a terminating PropertyNotFoundStrict
error, so `irm https://cli.oomol.com/install.ps1 | iex` fails.

Detect the architecture from PROCESSOR_ARCHITEW6432 (falling back
to PROCESSOR_ARCHITECTURE) instead. These work on every PowerShell
version and report the true host architecture, including the WOW64
case where the inbox 32-bit PowerShell 5.1 on ARM64 resolves to
arm64. The switch gains an amd64 case because that is the token
PROCESSOR_ARCHITECTURE reports on x64 Windows.

Verified on real Windows PowerShell 5.1 and PowerShell 7.6.

Signed-off-by: Kevin Cui <bh@bugs.cc>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10096fbd-e676-4123-aaeb-1478737d61fe

📥 Commits

Reviewing files that changed from the base of the PR and between 335ad49 and 8bfd6ba.

📒 Files selected for processing (1)
  • contrib/install/install-ps1.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • contrib/install/install-ps1.test.ts

Summary by CodeRabbit

  • Bug Fixes

    • Improved Windows installer detection to reliably recognize host architectures (including ARM64 and ARM64-on-x64) and map them to the correct platform identifiers; installer now fails with a clear error on unsupported architectures.
  • Tests

    • Added comprehensive test coverage for Windows architecture scenarios, including cross-architecture cases and negative-path validation, plus enhancements to the test harness for consistent PowerShell execution.

Walkthrough

This PR refactors Windows architecture detection in the installation script by replacing .NET runtime APIs with direct environment variable reads. The Resolve-Platform function now queries PROCESSOR_ARCHITEW6432 and PROCESSOR_ARCHITECTURE instead of calling [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture, with validation that at least one variable is present. Architecture tokens are mapped to Windows platform identifiers: arm64win32-arm64 and amd64win32-x64. Test coverage includes static assertions confirming the script uses the correct variables, a helper function to execute PowerShell commands, and a dynamic test matrix validating platform resolution across multiple architecture scenarios and unsupported inputs.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required format <type>(<scope>): <subject> with type 'fix', scope 'install', and a clear subject describing the main change to architecture detection.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem being fixed (RuntimeInformation absence issue), the solution (environment variable detection), and verification details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix-win-install

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contrib/install/install-ps1.test.ts`:
- Around line 287-303: The test is nondeterministic because runPowerShellCommand
forwards process.env including override vars like OO_INSTALL_PLATFORM that can
short-circuit Resolve-Platform; fix runPowerShellCommand by creating a shallow
copy of process.env, delete/clear OO_INSTALL_PLATFORM (and any other install
override variables you want neutralized), and pass that sanitized env object to
Bun.spawnSync instead of process.env so Resolve-Platform runs with a clean
environment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53dff96f-1cda-4f11-9902-551748224ab1

📥 Commits

Reviewing files that changed from the base of the PR and between 6cdcf71 and 335ad49.

📒 Files selected for processing (2)
  • contrib/install/install-ps1.test.ts
  • contrib/install/install.ps1

Comment thread contrib/install/install-ps1.test.ts
runPowerShellCommand forwarded the full process environment, so an
externally set OO_INSTALL_PLATFORM would short-circuit Resolve-Platform
and make the architecture-detection tests nondeterministic. Clear that
variable in the spawned environment so the tests always exercise the
real detection path.

Signed-off-by: Kevin Cui <bh@bugs.cc>
@BlackHole1 BlackHole1 merged commit 316d78f into main Jun 9, 2026
6 checks passed
@BlackHole1 BlackHole1 deleted the fix-win-install branch June 9, 2026 06:47
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.

1 participant