From 95ab8c787d60933d5b3aea814311c2eeb03b714f Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sat, 31 Oct 2026 20:23:56 +0800 Subject: [PATCH] fix(agent): prefer npx and uvx over emulated x64 binaries on Windows ARM64 --- crates/ide-agent/src/registry.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ide-agent/src/registry.rs b/crates/ide-agent/src/registry.rs index 6b3d2285e..26bf31f3f 100644 --- a/crates/ide-agent/src/registry.rs +++ b/crates/ide-agent/src/registry.rs @@ -211,12 +211,6 @@ fn choose<'a>(entry: &'a Entry, platform: Platform, on_path: &dyn Fn(&str) -> bo if let Some(b) = d.binary.get(&platform_key(platform)) { return Some(Choice::Binary(b)); } - if platform.os == Os::Windows - && platform.arch == Arch::Arm64 - && let Some(b) = d.binary.get("windows-x86_64") - { - return Some(Choice::Binary(b)); - } if let Some(p) = &d.npx && on_path("npm") && on_path("node") @@ -228,6 +222,13 @@ fn choose<'a>(entry: &'a Entry, platform: Platform, on_path: &dyn Fn(&str) -> bo { return Some(Choice::Uvx(p)); } + // Last resort: npx and uvx run natively, this one under OS emulation. + if platform.os == Os::Windows + && platform.arch == Arch::Arm64 + && let Some(b) = d.binary.get("windows-x86_64") + { + return Some(Choice::Binary(b)); + } None } @@ -701,6 +702,8 @@ mod tests { let arm = Platform { os: Os::Windows, arch: Arch::Arm64 }; assert!(matches!(choose(&entry, arm, &|_| false), Some(Choice::Binary(_)))); assert!(choose(&entry, Platform { os: Os::Linux, arch: Arch::Arm64 }, &|_| false).is_none()); + entry.distribution.npx = Some(serde_json::from_str(r#"{"package":"amp-acp"}"#).unwrap()); + assert!(matches!(choose(&entry, arm, &|_| true), Some(Choice::Npx(_)))); let mut native = entry.distribution.binary["windows-x86_64"].clone(); native.cmd = "native.exe".into(); entry.distribution.binary.insert("windows-aarch64".into(), native);