fix(npx): execute unknown targets via npx, not npm (#1495)#1527
Closed
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
Closed
fix(npx): execute unknown targets via npx, not npm (#1495)#1527ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
Conversation
The `Commands::Npx` fallback in main.rs delegated to `npm_cmd::run`, which runs the binary through `npm`. For any target without a matching `package.json` script entry (e.g. `oxlint`, third-party CLIs), `npm` injects `run` and fails with "Missing script: <target>". Users invoking `npx oxlint --fix` saw their lint runs broken because the rewrite turned a binary-lookup into a script-lookup. Fix: replace the `npm_cmd::run` fallback with a proper `npx` passthrough that mirrors the existing `npx prisma` fallback at the same call site — spawn `npx` directly, propagate the exit code, and record the invocation via `track_passthrough` so it still appears in `rtk gain --history`. Also add a parser-level regression test ensuring `npx oxlint --fix src/` routes through `Commands::Npx` (the dispatcher entrypoint that now leads to the corrected fallback). Closes rtk-ai#1495 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
📊 Automated PR Analysis
SummaryFixes the Review Checklist
Linked issues: #1495 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Collaborator
|
Closing as #1458 already took care of the problem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
rtk npx <unknown_binary>(e.g.npx oxlint) failed withnpm ERR! Missing script: \"<binary>\"instead of running the binary.Root cause
src/main.rsCommands::Npx fallback callednpm_cmd::run(&args, ...).npm_cmd::runinvokesnpmand (when args don't match a known npm subcommand) injectsrun, turningrtk npx oxlintintonpm run oxlint. Any binary not declared as apackage.jsonscript broke.Fix
Replace the
npm_cmd::runfallback with a propernpxpassthrough — the same pattern already used a few lines above fornpx prisma <unknown>:This restores correct binary-lookup semantics (npx) instead of script-lookup (npm), keeps tracking visible in
rtk gain --history, and propagates the child exit code.Test plan
Closes #1495