Skip to content

fix(cua-driver): install.ps1 OSArchitecture lookup under StrictMode Latest - #1631

Merged
f-trycua merged 1 commit into
mainfrom
fix/install-ps1-osarchitecture-strictmode
May 21, 2026
Merged

fix(cua-driver): install.ps1 OSArchitecture lookup under StrictMode Latest#1631
f-trycua merged 1 commit into
mainfrom
fix/install-ps1-osarchitecture-strictmode

Conversation

@f-trycua

@f-trycua f-trycua commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

irm install.ps1 | iex fails immediately on a fresh user account with:

iex : The property 'OSArchitecture' cannot be found on this object. Verify that the property exists.

Source: Get-TargetTriple's [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture call. Under Set-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_ARCHITECTURE as the primary architecture source — always set on Windows, never trips StrictMode, no .NET version dependency. RuntimeInformation.OSArchitecture is kept as a try/catch fallback for edge configurations where PROCESSOR_ARCHITECTURE is unset.

Source Value Triple
PROCESSOR_ARCHITECTURE AMD64 x86_64-pc-windows-msvc
PROCESSOR_ARCHITECTURE ARM64 aarch64-pc-windows-msvc
RuntimeInformation fallback X64 x86_64-pc-windows-msvc
RuntimeInformation fallback Arm64 aarch64-pc-windows-msvc

Repro

Provision a fresh non-RID-500 admin user on Windows 11 24H2:

net user testuser P@ssw0rd! /add /Y
net localgroup Administrators testuser /add

Log in as testuser, open non-elevated PowerShell, run:

irm https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.ps1 | iex

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.ps1 parses cleanly on PS 5.1.26100.8457 (3,169 tokens, 0 errors)
  • Smoke test: invoke Get-TargetTriple under Set-StrictMode -Version Latest returns x86_64-pc-windows-msvc cleanly
  • End-to-end fresh-install dogfood by the user from the new cuademo RDP session

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced Windows system architecture detection during the installation process with more robust fallback mechanisms to improve overall compatibility and reliably prevent detection failures across different system configurations
    • Improved error messages to clearly communicate supported processor architectures (AMD64 and ARM64) and provide better troubleshooting guidance when unsupported systems are encountered during installation

Review Change Stack

…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>
@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored May 21, 2026 3:50pm

Request Review

@f-trycua
f-trycua merged commit 0a84c2b into main May 21, 2026
6 of 7 checks passed
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9801d0ae-6999-4ae1-b9c6-ab7fbe396b0c

📥 Commits

Reviewing files that changed from the base of the PR and between 8d8f530 and 8b1772c.

📒 Files selected for processing (1)
  • libs/cua-driver/scripts/install.ps1

📝 Walkthrough

Walkthrough

This PR modifies the Get-TargetTriple function in the Windows installer script to detect system architecture. The function now prefers the PROCESSOR_ARCHITECTURE environment variable and falls back to .NET runtime information within a try/catch block, updating error messages to align with the new architecture naming convention.

Changes

Windows architecture detection fallback

Layer / File(s) Summary
Get-TargetTriple fallback and error handling
libs/cua-driver/scripts/install.ps1
Get-TargetTriple now prioritizes $env:PROCESSOR_ARCHITECTURE over RuntimeInformation.OSArchitecture with exception-guarded fallback. Error messages updated to reference the environment variable output and list AMD64/ARM64 as supported architectures instead of X64/Arm64.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • trycua/cua#1540: Both PRs modify install.ps1 Windows architecture detection in Get-TargetTriple, with this PR updating the preference chain to use environment variables and improved error messaging.

Poem

🐰 A rabbit hops through Windows paths so wide,
Architecture detection now has cleaner stride,
Preferring env first, with fallback so tight,
Error messages glow with AMD64 light! 🏗️

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/install-ps1-osarchitecture-strictmode

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.

❤️ Share

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

@f-trycua
f-trycua deleted the fix/install-ps1-osarchitecture-strictmode branch May 21, 2026 15:50
f-trycua added a commit that referenced this pull request May 22, 2026
…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>
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