rtk-ai/rtk · error

bunx requires a command argument

Error message

bunx requires a command argument

What it means

rtk's `bunx` proxy command routes the given tool to a specialized filter (tsc, eslint) or a generic bunx runner. This error is thrown when `bunx` is invoked with no arguments at all, since there is nothing to execute. It is an input-validation guard in `run_bunx_tool` (src/main.rs:1450).

Source

Thrown at src/main.rs:1450

    Compile {
        #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
        args: Vec<String>,
    },
    /// Install dependencies
    Install {
        #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
        args: Vec<String>,
    },
    /// Passthrough
    #[command(external_subcommand)]
    Other(Vec<OsString>),
}

/// Route `bunx <tool>` and `bun x <tool>` to the matching tool filter,
/// falling back to the generic bunx runner for unrecognized tools.
fn run_bunx_tool(args: &[String], verbose: u8, skip_env: bool) -> Result<i32> {
    if args.is_empty() {
        anyhow::bail!("bunx requires a command argument");
    }
    match args[0].as_str() {
        "tsc" | "typescript" => tsc_cmd::run(Some("bunx"), &args[1..], verbose),
        "eslint" => lint_cmd::run(Some("bunx"), args, verbose),
        _ => bun_cmd::run_bunx(args, verbose, skip_env),
    }
}

fn run_fallback(parse_error: clap::Error) -> Result<i32> {
    let args: Vec<String> = std::env::args().skip(1).collect();

    // No args → show Clap's error (user ran just "rtk" with bad syntax)
    if args.is_empty() {
        parse_error.exit();
    }

    // RTK meta-commands should never fall back to raw execution.
    // e.g. `rtk gain --badtypo` should show Clap's error, not try to run `gain` from $PATH.

View on GitHub (pinned to 36788f6bd4)

Solutions

  1. Pass the tool to execute: `rtk bunx tsc --noEmit`
  2. Check that any shell variable interpolating the command (e.g. `$TOOL`) is non-empty
  3. If using `rtk bun x`, ensure the tool name follows the `x` subcommand

Example fix

// before
rtk bunx
// after
rtk bunx prettier --write .
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$1" ]; then echo "usage: rtk bunx <tool> [args...]" >&2; exit 2; fi
rtk bunx "$@"

Try / catch

rtk bunx "$@" || { echo "bunx invocation failed (check a tool argument was passed)" >&2; exit $?; }

Prevention

When it happens

Trigger: Running `rtk bunx` (or `rtk bun x`) with an empty `args` slice — i.e. no tool/command specified after bunx.

Common situations: Shell variable holding the tool name is empty; a script builds the bunx invocation dynamically and drops the command; a user forgets the package name; an alias wraps `rtk bunx` and arguments get lost.

Related errors


AI-assisted analysis of rtk-ai/rtk@36788f6bd4 (2026-09-03). Data as JSON: /api/errors/9019f25bf098837e. Report an issue: GitHub.