rtk-ai/rtk · error
npx requires a command argument
Error message
npx requires a command argument
What it means
`rtk npx` proxies npm's `npx`, which needs a package/binary plus command to execute. When the args vector after `npx` is empty, src/main.rs:2765 bails with `anyhow::bail!` because there is nothing to route to the specialized filters (tsc, eslint, etc.) or the passthrough executor.
Solutions
- Pass the command you want to run, e.g. `rtk npx vitest run` or `rtk npx tsc --noEmit`
- Check that any variable interpolated into the command is non-empty before invoking
- Use plain `npx --help` (outside rtk) if you only wanted npx usage information
Example fix
// before (PKG empty) rtk npx $PKG // after rtk npx vitest run
Defensive patterns
Strategy: validation
Validate before calling
// shell: require a non-empty command before invoking rtk npx
if [ -z "${1:-}" ]; then echo "usage: rtk npx <command> [args...]" >&2; exit 1; fi
rtk npx "$@" Try / catch
// Rust caller
if args.is_empty() {
eprintln!("rtk npx requires a command, e.g. rtk npx tsc --noEmit");
std::process::exit(2);
}
rtk_npx(&args)?; Prevention
- Always quote/verify interpolated variables before `rtk npx $VAR`
- Invoke rtk npx with at least a binary name plus args
- Add usage text in wrapper scripts when arg count is 0
When it happens
Trigger: Running `rtk npx` with no further arguments (e.g. typing `rtk npx` alone, or a script building the command from a variable that ended up empty).
Common situations: A shell variable holding the package name is unset (`rtk npx $PKG`); a fat command alias lost its arguments; forgetting that unlike bare `npx` (which prints help), rtk requires an explicit command.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- at least one of install_claude or install_opencode must be…
- dotnet: no subcommand specified
- go: no subcommand specified
- gt: no subcommand specified
- proxy requires a command to execute Usage: rtk proxy
AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19).
Data as JSON: /api/errors/c61543dd919a2e7e.
Report an issue: GitHub.
Appendix: source
Thrown at src/main.rs:2765
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(Some("npx"), &args[1..], cli.verbose)?,
"eslint" => lint_cmd::run(Some("npx"), &args, 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 0924356b4c)