From 9418a3a8be295ef68946f9e42b1f64c012b2eb68 Mon Sep 17 00:00:00 2001 From: can1357 Date: Wed, 13 May 2026 06:29:18 +0200 Subject: [PATCH] ci(scripts/run-rs-task): resolved cargo via rustup which to dodge homebrew rustup-init shadow on macos --- scripts/run-rs-task.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/run-rs-task.ts b/scripts/run-rs-task.ts index 523d32813..302715808 100644 --- a/scripts/run-rs-task.ts +++ b/scripts/run-rs-task.ts @@ -40,6 +40,7 @@ const TASK_COMMANDS = { type RustTaskName = keyof typeof TASK_COMMANDS; const repoRoot = path.join(import.meta.dir, ".."); +const cargoBinary = await resolveCargoBinary(); const taskName = process.argv[2]; if (!isRustTaskName(taskName)) { @@ -121,8 +122,23 @@ function isOneOf(value: string, values: readonly T[]): value i return values.some(entry => entry === value); } +async function resolveCargoBinary(): Promise { + // On macOS runners, Homebrew's `rustup-init` binary is on PATH before the + // rustup proxies in `$CARGO_HOME/bin`, and invoking it as `cargo` falls + // through to its installer mode ("unexpected argument 'nextest' found"). + // Ask rustup directly for the cargo binary in the active toolchain. + const result = await $`rustup which cargo`.cwd(repoRoot).quiet().nothrow(); + if (result.exitCode === 0) { + const resolved = result.stdout.toString().trim(); + if (resolved !== "") return resolved; + } + return "cargo"; +} + async function runCommand(command: readonly string[]): Promise { - const proc = Bun.spawn([...command], { + const [head, ...rest] = command; + const argv = head === "cargo" ? [cargoBinary, ...rest] : [head, ...rest]; + const proc = Bun.spawn(argv, { cwd: repoRoot, stdin: "inherit", stdout: "inherit",