(#1803) Add native Windows on ARM (arm64) detection#3907
Conversation
choco treated every ARM64 host as 32-bit (x86). When that code was written, Windows on ARM only shipped an x86 emulator, but Windows 11 now provides x64 emulation and many applications ship native arm64 builds, so the assumption is obsolete and forces emulated x86 packages onto arm64 users. Detect the operating system's native architecture reliably through the IsWow64Process2 Win32 API, which is correct even when choco.exe runs under emulation (PROCESSOR_ARCHITECTURE and RuntimeInformation.OSArchitecture report the emulated architecture). It is exposed on the IEnvironment adapter as NativeProcessorArchitecture and IsArm64OperatingSystem. Remove the workarounds that forced ARM64 to 32-bit in Environment.Is64BitProcess and Get-OSArchitectureWidth so arm64 hosts use x64 emulation. Surface the native architecture to package scripts via a new OS_PROCESSOR_ARCHITECTURE environment variable and a new Get-OSArchitecture helper returning x86, x64 or arm64. Add native windows-11-arm jobs to the build and test workflows (as a matrix with the existing x64 Windows jobs) so choco is built and unit-tested on real Windows on ARM hardware.
|
Hey @dennisameling thank you for taking the time to put this together! We’ll want to carefully review and validate the changes here. I’m not able to give an ETA on review at the moment, but we appreciate your patience while we evaluate it. |
Add <supportedArchitectures>amd64 arm64</supportedArchitectures> to choco.exe.manifest so the AnyCPU CLI runs natively as ARM64 on Windows 11 24H2+ rather than x64-emulated (the .NET Framework AnyCPU default on Windows on ARM). Older hosts ignore the element and fall back to x64 emulation. Also correct comments that assumed the CLI always runs emulated on ARM. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…64 constant Add Pester tests for Get-OSArchitecture and Get-OSArchitectureWidth that validate sane, OS-consistent values on both x64 and Windows on ARM (arm64) runners. Mark ApplicationParameters.Environment.Arm64ProcessorArchitecture obsolete: it is no longer referenced now that ARM64 detection goes through IEnvironment (NativeProcessorArchitecture / IsArm64OperatingSystem). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
I just ran some tests and can confirm this is working as expected on arm64 Windows host. Combined with chocolatey-community/chocolatey-packages#2796, here's a successful installation of Firefox arm64 (notice In Task Manager I could see that
I have some questions for the maintainers:
Some other notes: Native ARM64 execution + heads-up for package authors
|

Description Of Changes
Adds reliable native processor-architecture detection to Chocolatey CLI and removes the long-standing workaround that forced every Windows on ARM (arm64) host to be treated as 32-bit (x86).
NativeProcessorArchitectureandIsArm64OperatingSystemmembers on theIEnvironmentadapter determine the operating system's native architecture (x86/x64/arm64) through the Win32IsWow64Process2API. This is accurate even whenchoco.exeruns under emulation on Windows on ARM, wherePROCESSOR_ARCHITECTUREandRuntimeInformation.OSArchitecturereport the emulated architecture instead.Environment.Is64BitProcessandGet-OSArchitectureWidth. With Windows 11 x64 emulation, arm64 hosts now report 64-bit rather than being limited to x86.OS_PROCESSOR_ARCHITECTUREenvironment variable and a newGet-OSArchitecturehelper that returnsx86,x64, orarm64.windows-11-armbuild and test jobs to the GitHub Actions workflows, folded into a matrix alongside the existing x64 Windows jobs.This is the foundational step (architecture detection + native CI). Package-author-facing arm64 asset selection (
urlArm64/checksumArm64/fileArm64,tools\arm64shimming) and native arm64 bundled tooling are intended as follow-up work toward the broader arm64 support tracked in #1803.Motivation and Context
On Windows on ARM, Chocolatey previously selected the 32-bit (x86) variant of every package. That behaviour dates to a 2019 assumption (called out in the old
Get-OSArchitectureWidthnotes) that Windows on ARM would only ever provide an x86 emulator. That is no longer true: Windows 11 ships x64 emulation, and a growing number of applications publish native arm64 builds. As a result, arm64 users get slower x86-emulated software today, and some packages fail outright when they ship only x64 (or arm64) assets.The previous detection was also unreliable. Because
choco.exeis a .NET Framework process that itself runs under emulation on arm64, its in-processPROCESSOR_ARCHITECTUREreportsAMD64/x86and neverARM64.IsWow64Process2is the supported Win32 API that reports the true native architecture regardless of emulation.GitHub Actions now provides free
windows-11-armrunners for public repositories, which makes it possible to build and unit-test choco natively on Windows on ARM.Testing
Environmentadapter unit specs (EnvironmentSpecs) to cover the newNativeProcessorArchitecture/IsArm64OperatingSystemmembers and the revisedIs64BitProcessbehaviour, then ran the unit-test suite.0 Error(s)and the unit suite passes (1190 passed, 2 pre-existing skips) on both architectures.Operating Systems Testing
windows-latestwindows-11-armChange Types Made
On Windows 11 on ARM, package architecture selection changes from x86 to x64, so this is flagged as a behaviour change.
Change Checklist
The new
Get-OSArchitecturehelper andOS_PROCESSOR_ARCHITECTUREvariable warrant documentation in the docs repository. The helper is PowerShell v2-compatible (it usesGet-WmiObjectrather thanGet-CimInstance).Related Issue
Relates to #1803
Fixes #2172