From fa361a523727f4f0aee1806fd185311f35130e85 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 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 77a4be8c3..bb4e7ed6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1871,8 +1871,22 @@ fn run_cli() -> Result { "prettier" => prettier_cmd::run(&args[1..], cli.verbose)?, "playwright" => playwright_cmd::run(&args[1..], cli.verbose)?, _ => { - // Generic passthrough with npm boilerplate filter - npm_cmd::run(&args, cli.verbose, cli.skip_env)? + // Passthrough via npx (not npm) — unknown tools need npx directly. + let timer = core::tracking::TimedExecution::start(); + let mut cmd = core::utils::resolved_command("npx"); + cmd.args(&args); + if cli.skip_env { + cmd.env("SKIP_ENV_VALIDATION", "1"); + } + let cmd_label = format!("npx {}", args.join(" ")); + let status = cmd.status().with_context(|| { + format!("Failed to run `{cmd_label}`. Is npx on PATH?") + })?; + timer.track_passthrough( + &cmd_label, + &format!("rtk {cmd_label} (passthrough)"), + ); + core::utils::exit_code_from_status(&status, &cmd_label) } } }