BoundaryML/baml · warning

Usage: :load (or :l )

Error message

Usage: :load <path> (or :l <path>)

What it means

REPL usage error: the `:load` (or `:l`) command was given an argument count other than exactly one. The command requires a single path argument to the baml sources directory; the arg-count check fires before any loading is attempted.

Solutions

  1. Provide exactly one path: :load <path-to-baml_src>
  2. Quote paths containing spaces: :load "/path/with spaces/baml_src"
  3. Run :help to confirm command syntax

Example fix

// before
:load ./my project/src
// after
:load "./my project/src"
Defensive patterns

Strategy: validation

Validate before calling

// Validate argument count before invoking
let args: Vec<&str> = input[1..].split_whitespace().skip(1).collect();
let ok = args.len() == 1;
// Quote paths containing spaces: :load "/path/with spaces"

Try / catch

match result { Err(e) if e.to_string().starts_with("Usage: :load") => println!("{e}; example: :load ./baml_src"), other => { let _ = other; } }

Prevention

When it happens

Trigger: :load with zero arguments (:load) or more than one (:load ./a ./b) — parts.len() != 2 in handle_command.

Common situations: Forgetting the path argument, paths containing spaces that were not quoted so they split into multiple tokens, pasting a command with trailing junk.

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


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

Appendix: source

Thrown at engine/baml-runtime/src/cli/repl.rs:1645

        // Ensure the progress bar is hidden on exit
        if supports_progress && progress_active {
            send_graphical_progress(0);
        }
        println!("Goodbye!");
        Ok(())
    }

    #[allow(clippy::print_stdout)]
    fn handle_command(&self, state: &mut ReplState, input: &str) -> Result<Option<String>> {
        let parts: Vec<&str> = input[1..].split_whitespace().collect();
        if parts.is_empty() {
            return Err(anyhow!("Empty command"));
        }

        match parts[0] {
            "load" | "l" => {
                if parts.len() != 2 {
                    return Err(anyhow!("Usage: :load <path> (or :l <path>)"));
                }
                let path = PathBuf::from(parts[1]);
                state.load_baml_sources(path)?;
                Ok(Some("".to_string())) // Success message already printed
            }
            "reset" | "r" => {
                state.reset();
                Ok(Some("".to_string())) // Success message already printed
            }
            "vars" | "v" => Ok(Some(state.list_variables())),
            "thir" => match state.dump_thir() {
                Ok(output) => Ok(Some(output)),
                Err(e) => Err(e),
            },
            "type" | "t" => {
                if parts.len() < 2 {
                    return Err(anyhow!("Usage: :type <expression> (or :t <expression>)"));
                }

View on GitHub (pinned to bd85ce9dee)