Skip to content

fix(npm): strip leading "run" arg to prevent npm run run <script>#440

Closed
jackfreem wants to merge 1 commit intortk-ai:masterfrom
jackfreem:jackf/fix-npm-run-prefix
Closed

fix(npm): strip leading "run" arg to prevent npm run run <script>#440
jackfreem wants to merge 1 commit intortk-ai:masterfrom
jackfreem:jackf/fix-npm-run-prefix

Conversation

@jackfreem
Copy link

@jackfreem jackfreem commented Mar 9, 2026

Why

rtk npm run build silently invokes npm run run build because npm_cmd::run() unconditionally injects "run" before forwarding args, but Clap already captures "run" as part of the trailing args. This produces npm's "Missing script: run" error (issue #438).

What

  • Strip a leading "run" arg in npm_cmd::run() before building the command, so both rtk npm run build and rtk npm build correctly invoke npm run build
  • Add two unit tests covering the stripping logic: one with the prefix present, one without

References

Fixes #438.

This is a minimal fix (Path A). The long-term solution (Path B) is to introduce a structured NpmCommands sub-enum with Run, Install, Build, etc. variants — enabling smart filter routing (npm run test → vitest filter, npm run build → next_cmd filter). PR #232 did exactly this for pnpm and is the direct precedent to follow.

…e-invocation

`npm_cmd::run()` unconditionally injects `"run"` before passing args to npm.
When a user calls `rtk npm run build`, Clap captures args as ["run", "build"],
which then becomes `npm run run build` — triggering "Missing script: run".

Strip a leading "run" arg so both `rtk npm run build` and `rtk npm build`
correctly invoke `npm run build`.

Fixes rtk-ai#438
@jackfreem
Copy link
Author

Solved in #458

@jackfreem jackfreem closed this Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'rtk npm run build' is expecting to be run as 'rtk npm build', which confuses the LLM

1 participant