BoundaryML/baml · info

No BAML sources loaded. Use :load <path> to load sources.

Error message

No BAML sources loaded. Use :load <path> to load sources.

What it means

The BAML REPL's `dump_thir` command inspects the THIR/HIR of loaded sources. If no runtime has been created yet — i.e., no sources were loaded with `:load` — it bails with this instructive message. It's an expected precondition failure, not a bug.

Source

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

        diagnostics.set_source(&(PathBuf::from("repl"), "function_parameters").into());
        let (thir, _) = typecheck_returning_context(&hir, &mut diagnostics);
        Ok(thir
            .llm_functions
            .iter()
            .map(|f| {
                (
                    f.name.clone(),
                    f.parameters.iter().map(|p| p.name.clone()).collect(),
                )
            })
            .collect())
    }

    fn dump_thir(&self) -> Result<String> {
        let runtime = self
            .runtime
            .as_ref()
            .ok_or_else(|| anyhow!("No BAML sources loaded. Use :load <path> to load sources."))?;

        let internal = &runtime;

        // Convert AST to HIR
        let hir = Hir::from_ast(&internal.db.ast);

        // Typecheck HIR to get THIR
        let mut diagnostics = Diagnostics::default();
        let (thir, _) = typecheck_returning_context(&hir, &mut diagnostics);

        // Format the THIR for display
        let mut output = String::new();
        output.push_str("=== TYPED HIGH-LEVEL INTERMEDIATE REPRESENTATION (THIR) ===\n\n");

        // Display global assignments
        if !thir.global_assignments.is_empty() {
            output.push_str("Global Assignments:\n");
            for (name, ga) in &thir.global_assignments {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Run `:load <path/to/baml_src>` first, then retry the dump command.
  2. If you already ran :load, check its output for load errors — the runtime stays None if loading failed.
  3. Use the correct path to a directory containing .baml files (e.g. baml_src).
  4. Run `:help` to see the exact load/dump command names.

Example fix

// REPL session
// before
> :dump-thir
No BAML sources loaded...
// after
> :load ./baml_src
> :dump-thir
Defensive patterns

Strategy: try-catch

Validate before calling

// REPL: check state before dumping (conceptual)
if (!runtimeLoaded) { console.log('run :load <path> first'); }

Type guard

const hasRuntime = (repl) => repl.runtime != null;

Try / catch

catch (e) {
  if (String(e.message).includes('No BAML sources loaded')) {
    // print hint: use :load <path> before dump commands
  }
}

Prevention

When it happens

Trigger: Running `:dump-thir` (or whatever REPL command invokes dump_thir) in a fresh REPL session before any `:load <path>` succeeded.

Common situations: Starting the REPL and immediately running dump commands, a prior `:load` failed silently leaving self.runtime as None, or mis-typed :load path.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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