{"record":{"id":"edc826befc87b1e8","repo":"BoundaryML/baml","slug":"no-baml-files-found-in-run-command","errorCode":null,"errorMessage":"no `.baml` files found in {}","messagePattern":"no `\\.baml` files found in (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":842,"sourceCode":"    }\n\n    /// Load the project (or standalone `--file`), check diagnostics,\n    /// compile to bytecode, create engine.\n    fn load_and_compile(&self, argv: Vec<String>, reporter: &Reporter) -> Result<Compiled> {\n        if let Some(file) = self.file.as_deref() {\n            return self.load_and_compile_standalone(file, argv, reporter);\n        }\n\n        let mut session = crate::project_session::ProjectSession::open(\n            self.from.as_deref(),\n            crate::project_session::CacheUse::ReadWrite,\n        )?;\n        self.vlog(format_args!(\n            \"Loading project from {}\",\n            session.root().display()\n        ));\n        if session.is_empty() {\n            anyhow::bail!(\"no `.baml` files found in {}\", session.root().display());\n        }\n        self.vlog(format_args!(\"Found {} .baml file(s)\", session.file_count()));\n        let needs_format_hint = session.needs_format_hint();\n\n        if let Some(program) = session.try_cached_program() {\n            self.vlog(format_args!(\"Bytecode cache hit — skipping compile\"));\n            match BexEngine::new_with_runtime_compiler(\n                program,\n                Arc::new(sys_native::SysOps::native()),\n                argv.clone(),\n                bex_project::runtime_compiler(),\n            ) {\n                Ok(engine) => {\n                    return Ok(Compiled {\n                        db: session.db,\n                        package: session.package,\n                        engine,\n                        needs_format_hint,","sourceCodeStart":824,"sourceCodeEnd":860,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L824-L860","documentation":"Raised during project loading when the project root (or --from directory) contains no *.baml source files. ProjectSession::open succeeded in finding a directory, but the glob for BAML sources came back empty — the sources may be in a subdirectory not searched, a wrong --from path was given, or the files use a different extension.","triggerScenarios":"`load_and_compile` finds `session.is_empty()` after loading the project directory — no files matching `*.baml` exist under the resolved project root.","commonSituations":"Running `baml run` outside a BAML project or in an empty directory; misconfigured project root in `baml.toml`; all `.baml` files moved/deleted or renamed with a wrong extension.","solutions":["Run from the directory containing `baml_src/` with `.baml` files, or pass the correct project path","Verify `.baml` files exist under the project root shown in the error","Check the project root configuration in `baml.toml`"],"exampleFix":"# before (wrong dir)\ncd ./empty_dir && baml run -f MyFn\n# after\ncd ./my_project && baml run -f MyFn","handlingStrategy":"validation","validationCode":"const { globSync } = require('glob'); if (globSync('**/*.baml', { cwd: projectRoot }).length === 0) throw new Error(`no .baml files in ${projectRoot}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run baml run from a directory containing .baml sources","Verify project root / baml.toml location before invoking","Keep .baml extension intact when renaming files"],"tags":["cli","file-not-found","empty-project","baml"],"backgroundTag":"file-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}