{"record":{"id":"f8d9eb8e860f0394","repo":"BoundaryML/baml","slug":"no-baml-sources-loaded-use-load-path-to-load-sources","errorCode":null,"errorMessage":"No BAML sources loaded. Use :load <path> to load sources.","messagePattern":"No BAML sources loaded\\. Use :load <path> to load sources\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"engine/baml-runtime/src/cli/repl.rs","lineNumber":314,"sourceCode":"        diagnostics.set_source(&(PathBuf::from(\"repl\"), \"function_parameters\").into());\n        let (thir, _) = typecheck_returning_context(&hir, &mut diagnostics);\n        Ok(thir\n            .llm_functions\n            .iter()\n            .map(|f| {\n                (\n                    f.name.clone(),\n                    f.parameters.iter().map(|p| p.name.clone()).collect(),\n                )\n            })\n            .collect())\n    }\n\n    fn dump_thir(&self) -> Result<String> {\n        let runtime = self\n            .runtime\n            .as_ref()\n            .ok_or_else(|| anyhow!(\"No BAML sources loaded. Use :load <path> to load sources.\"))?;\n\n        let internal = &runtime;\n\n        // Convert AST to HIR\n        let hir = Hir::from_ast(&internal.db.ast);\n\n        // Typecheck HIR to get THIR\n        let mut diagnostics = Diagnostics::default();\n        let (thir, _) = typecheck_returning_context(&hir, &mut diagnostics);\n\n        // Format the THIR for display\n        let mut output = String::new();\n        output.push_str(\"=== TYPED HIGH-LEVEL INTERMEDIATE REPRESENTATION (THIR) ===\\n\\n\");\n\n        // Display global assignments\n        if !thir.global_assignments.is_empty() {\n            output.push_str(\"Global Assignments:\\n\");\n            for (name, ga) in &thir.global_assignments {","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/cli/repl.rs#L296-L332","documentation":"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.","triggerScenarios":"Running `:dump-thir` (or whatever REPL command invokes dump_thir) in a fresh REPL session before any `:load <path>` succeeded.","commonSituations":"Starting the REPL and immediately running dump commands, a prior `:load` failed silently leaving self.runtime as None, or mis-typed :load path.","solutions":["Run `:load <path/to/baml_src>` first, then retry the dump command.","If you already ran :load, check its output for load errors — the runtime stays None if loading failed.","Use the correct path to a directory containing .baml files (e.g. baml_src).","Run `:help` to see the exact load/dump command names."],"exampleFix":"// REPL session\n// before\n> :dump-thir\nNo BAML sources loaded...\n// after\n> :load ./baml_src\n> :dump-thir","handlingStrategy":"try-catch","validationCode":"// REPL: check state before dumping (conceptual)\nif (!runtimeLoaded) { console.log('run :load <path> first'); }","typeGuard":"const hasRuntime = (repl) => repl.runtime != null;","tryCatchPattern":"catch (e) {\n  if (String(e.message).includes('No BAML sources loaded')) {\n    // print hint: use :load <path> before dump commands\n  }\n}","preventionTips":["Always :load sources as your first REPL command.","Verify :load output shows success before dump commands.","Use :help to confirm command prerequisites."],"tags":["repl","baml","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}