From 94f932067b523dcf72ae233007febd175239b3af Mon Sep 17 00:00:00 2001 From: Devon Freitas Date: Sat, 21 Mar 2026 01:57:14 -0400 Subject: [PATCH] fix(npx): use npx (not npm) for unrecognized npx commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Npx handler's catch-all fallback called npm_cmd::run(), which invoked `npm` instead of `npx`. When npx flags preceded the tool name (e.g. `npx -y -p @playwright/cli playwright-cli list`), args[0] was a flag, not a tool name, so routing fell to the catch-all — which then ran the wrong binary entirely. Replace with direct npx passthrough matching the existing prisma passthrough pattern. Preserves SKIP_ENV_VALIDATION, tracking, and exit code propagation. Fixes rtk-ai/rtk#713 Co-Authored-By: Claude Opus 4.6 Signed-off-by: Devon Freitas --- src/main.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0ff5124c..9a62317a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2006,8 +2006,25 @@ fn main() -> Result<()> { playwright_cmd::run(&args[1..], cli.verbose)?; } _ => { - // Generic passthrough with npm boilerplate filter - npm_cmd::run(&args, cli.verbose, cli.skip_env)?; + // Passthrough to npx (not npm) — unrecognized tools get + // raw output since we can't predict their format. + let timer = tracking::TimedExecution::start(); + let mut cmd = utils::resolved_command("npx"); + cmd.args(&args); + if cli.skip_env { + cmd.env("SKIP_ENV_VALIDATION", "1"); + } + let args_str = args.join(" "); + let status = cmd.status().with_context(|| { + format!("Failed to run `npx {args_str}`. Is npx on PATH?") + })?; + timer.track_passthrough( + &format!("npx {}", args_str), + &format!("rtk npx {} (passthrough)", args_str), + ); + if !status.success() { + std::process::exit(status.code().unwrap_or(1)); + } } } }