fix(cua-driver): install.ps1 OSArchitecture lookup under StrictMode Latest - #1631
Conversation
…Mode Latest
irm | iex of install.ps1 on a fresh user account (Windows 11 24H2 PS 5.1)
fails immediately after the install-dir log lines with:
iex : The property 'OSArchitecture' cannot be found on this object.
Verify that the property exists.
The source is Get-TargetTriple's call to
[System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture. Under
Set-StrictMode -Version Latest (set at install.ps1:78), PowerShell 5.1
reports the static property access as a missing-property error in certain
session contexts — specifically a freshly-created admin user with no
profile, no prior loaded modules. The same script works fine under the
RID-500 built-in Administrator account on the same VM, which is why this
went undetected through the v0.2.9 install verification.
## Fix
Use $env:PROCESSOR_ARCHITECTURE as the primary source for the architecture
lookup. It's always set on Windows, never trips StrictMode introspection,
and has no .NET version dependency. RuntimeInformation.OSArchitecture is
kept as a try-catch fallback so we still handle exotic configurations
where PROCESSOR_ARCHITECTURE is unset.
Mapping:
AMD64 -> x86_64-pc-windows-msvc (PROCESSOR_ARCHITECTURE on x64)
ARM64 -> aarch64-pc-windows-msvc (PROCESSOR_ARCHITECTURE on arm64)
X64 -> x86_64-pc-windows-msvc (fallback: RuntimeInformation.Architecture.ToString())
Arm64 -> aarch64-pc-windows-msvc (fallback)
## Verification
- cargo check on the unrelated install path: clean (no code-side change)
- install.ps1 parses cleanly on PS 5.1.26100.8457
- Smoke test: invoke Get-TargetTriple under
`Set-StrictMode -Version Latest` -> returns 'x86_64-pc-windows-msvc' (no
PropertyNotFoundStrict error)
## Repro / how it surfaced
Reported by the cuademo test account (BUILTIN\Administrators, NOT RID 500,
UAC-split-token) on the Windows VM during the post-#1630 fresh-install
dogfood walkthrough.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR modifies the ChangesWindows architecture detection fallback
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r StrictMode (#1658) install-local.ps1 was using [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture which trips PowerShell's Set-StrictMode -Version Latest with: The property 'OSArchitecture' cannot be found on this object. Verify that the property exists. Same issue PR #1631 fixed for install.ps1. Applying the same fix here: use $env:PROCESSOR_ARCHITECTURE instead, which is a plain string StrictMode is happy with. Surfaced when running install-local.ps1 from a fresh fbonacci RDP shell that had StrictMode active (likely from a profile init script). Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Summary
irm install.ps1 | iexfails immediately on a fresh user account with:Source:
Get-TargetTriple's[System.Runtime.InteropServices.RuntimeInformation]::OSArchitecturecall. UnderSet-StrictMode -Version Latest(install.ps1:78), PS 5.1 reports the static property access as missing-property in certain session contexts — specifically a freshly-created admin user with no profile, no prior loaded modules. The script works fine under the RID-500 built-in Administrator on the same VM, which is why this went undetected through v0.2.9.Fix
Use
$env:PROCESSOR_ARCHITECTUREas the primary architecture source — always set on Windows, never trips StrictMode, no .NET version dependency.RuntimeInformation.OSArchitectureis kept as a try/catch fallback for edge configurations wherePROCESSOR_ARCHITECTUREis unset.PROCESSOR_ARCHITECTUREAMD64x86_64-pc-windows-msvcPROCESSOR_ARCHITECTUREARM64aarch64-pc-windows-msvcRuntimeInformationfallbackX64x86_64-pc-windows-msvcRuntimeInformationfallbackArm64aarch64-pc-windows-msvcRepro
Provision a fresh non-RID-500 admin user on Windows 11 24H2:
Log in as
testuser, open non-elevated PowerShell, run:Before this fix: hard fail after the "install dir" log line.
After this fix: install completes through to
cua-driver-rs 0.2.9 installed.Verification
install.ps1parses cleanly on PS 5.1.26100.8457 (3,169 tokens, 0 errors)Get-TargetTripleunderSet-StrictMode -Version Latestreturnsx86_64-pc-windows-msvccleanlycuademoRDP sessionRelated
🤖 Generated with Claude Code
Summary by CodeRabbit