BoundaryML/baml · error

no command `{}` for `{prefix}`. Available commands: {}

Error message

no command `{}` for `{prefix}`. Available commands:
    {}

What it means

Same custom help renderer as the sibling error, but for the common case: the nearest known command does have subcommands, so the error lists all available choices after the message. It fires whenever the unmatched portion of the command line cannot be matched to a subcommand.

Source

Thrown at baml_language/crates/baml_cli/src/help_command.rs:75

    let command = find_command(query, &root).map_err(|(unmatched, nearest)| {
        let prefix = if query.len() == unmatched.len() {
            "baml".to_string()
        } else {
            format!("baml {}", query[..query.len() - unmatched.len()].join(" "))
        };
        let choices = nearest
            .get_subcommands()
            .filter(|command| !command.is_hide_set() && command.get_name() != "help")
            .map(clap::Command::get_name)
            .collect::<Vec<_>>();
        if choices.is_empty() {
            anyhow!(
                "no command `{}` for `{prefix}`; `{prefix}` has no subcommands",
                unmatched.join(" ")
            )
        } else {
            anyhow!(
                "no command `{}` for `{prefix}`. Available commands:\n    {}",
                unmatched.join(" "),
                choices.join("\n    ")
            )
        }
    })?;

    let is_root = query.is_empty();
    let mut command = command.clone();
    let help = if is_root {
        command.render_help()
    } else {
        if command.get_after_long_help().is_none() {
            command = command.after_long_help("");
        }
        promote_examples(&mut command);
        if command.has_subcommands() {
            let hint = format!(

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Pick the correct command from the 'Available commands' list in the message
  2. Run `baml <prefix> --help` for full option details
  3. Update scripts/aliases that reference old subcommand names

Example fix

// before
$ baml toolchain instal canary
// after
$ baml toolchain install canary
Defensive patterns

Strategy: validation

Validate before calling

// verify the subcommand name before invoking
$ baml toolchain --help   # list exact subcommand names

Try / catch

if !ok {
    let msg = stderr;
    if let Some(list) = msg.split("Available commands:\n").nth(1) {
        eprintln!("Unknown subcommand. Did you mean one of: {list}?");
    }
}

Prevention

When it happens

Trigger: Typing an unknown or misspelled subcommand under a command that has subcommands, e.g. `baml generte` or `baml toolchain instal`; render_from collects visible subcommand names and raises this error with the list.

Common situations: Typos, outdated muscle memory after a CLI rename, or scripts referencing removed subcommands.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/3ee3c4bad034c437. Report an issue: GitHub.