rtk-ai/rtk · error

npx requires a command argument

Error message

npx requires a command argument

What it means

rtk npx is a filtering proxy around npx; with zero args there is no command to route — the dispatcher indexes args[0] to select the tsc/eslint/prisma/... filter. main validates this up front with a usage message instead of panicking on args[0].

Source

Thrown at src/main.rs:2315

            write_rules,
            min_confidence,
            min_occurrences,
        } => {
            learn::run(
                project,
                all,
                since,
                format,
                write_rules,
                min_confidence,
                min_occurrences,
            )?;
            0
        }

        Commands::Npx { args } => {
            if args.is_empty() {
                anyhow::bail!("npx requires a command argument");
            }

            // Intelligent routing: delegate to specialized filters
            match args[0].as_str() {
                "tsc" | "typescript" => tsc_cmd::run(&args[1..], cli.verbose)?,
                "eslint" => lint_cmd::run(&args[1..], cli.verbose)?,
                "prisma" => {
                    // Route to prisma_cmd based on subcommand
                    if args.len() > 1 {
                        let prisma_args: Vec<String> = args[2..].to_vec();
                        match args[1].as_str() {
                            "generate" => prisma_cmd::run(
                                prisma_cmd::PrismaCommand::Generate,
                                &prisma_args,
                                cli.verbose,
                            )?,
                            "db" if args.len() > 2 && args[2] == "push" => prisma_cmd::run(
                                prisma_cmd::PrismaCommand::DbPush,

View on GitHub (pinned to d977e1c316)

Solutions

  1. Pass the command: `rtk npx tsc --noEmit`
  2. Guard wrappers: `[ $# -ge 1 ] || { echo 'usage: rtk npx <cmd> [args...]'; exit 2; }`
  3. Enable `set -u` in scripts so unset variables fail before rtk is invoked

Example fix

# before
rtk npx "$MAYBE_EMPTY"

# after
rtk npx tsc --noEmit
Defensive patterns

Strategy: validation

Validate before calling

# bash: guard before proxying to rtk npx
[ $# -ge 1 ] && [ -n "$1" ] || { echo 'usage: rtk npx <cmd> [args...]' >&2; exit 2; }
rtk npx "$@"

Prevention

When it happens

Trigger: `rtk npx` with no arguments — typically a wrapper interpolating an unset variable: `rtk npx $TOOL` with TOOL empty (src/main.rs:2317).

Common situations: Shell wrappers passing through optional arguments; docs placeholders never replaced; `set -u` not enabled so empty vars slip through.

Related errors


AI-assisted analysis of rtk-ai/rtk@d977e1c316 (2026-08-16). Data as JSON: /api/errors/c61543dd919a2e7e. Report an issue: GitHub.