Skip to content

Commit c1d1765

Browse files
Fix Windows arch detection in install_cargo_binstall
archive_for_platform derived the Windows archive name from `uname -m`, but Git for Windows' MSYS runtime does not report the host's real architecture there: it reports the emulated x86_64 process architecture under WOW64, or "unknown" for a native arm64 host with no case in its uname implementation. On windows-11-arm this asked for cargo-binstall-unknown-pc-windows-msvc.zip, which has no pinned digest, and the script exited before installing anything. Derive the Windows architecture from PROCESSOR_ARCHITEW6432 (set only under WOW64/x64 emulation, to the true native architecture) falling back to PROCESSOR_ARCHITECTURE instead, so both a native arm64 host and an x64-emulated bash on an arm64 host resolve to the aarch64 archive. The x64 leg still resolves to the same x86_64 archive as before.
1 parent 6340166 commit c1d1765

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

script/install_cargo_binstall

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,17 @@ archive_for_platform() {
4343
echo "cargo-binstall-$(uname -m)-unknown-linux-musl.tgz" ;;
4444
*)
4545
if [ "${OS-}" = "Windows_NT" ]; then
46-
echo "cargo-binstall-$(uname -m)-pc-windows-msvc.zip"
46+
# uname -m is unreliable here: Git for Windows' MSYS runtime reports the
47+
# emulated x86_64 host under WOW64, or "unknown" on a native arm64 host,
48+
# rather than the real machine architecture. PROCESSOR_ARCHITEW6432 (set
49+
# only under emulation, to the true native architecture) falling back to
50+
# PROCESSOR_ARCHITECTURE reports it correctly in both cases.
51+
case "${PROCESSOR_ARCHITEW6432:-${PROCESSOR_ARCHITECTURE-}}" in
52+
ARM64)
53+
echo "cargo-binstall-aarch64-pc-windows-msvc.zip" ;;
54+
AMD64)
55+
echo "cargo-binstall-x86_64-pc-windows-msvc.zip" ;;
56+
esac
4757
fi
4858
;;
4959
esac

0 commit comments

Comments
 (0)