{"record":{"id":"1f3064bde442e701","repo":"BoundaryML/baml","slug":"no-baml-files-found-in","errorCode":null,"errorMessage":"no `.baml` files found in {}","messagePattern":"no `\\.baml` files found in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/pack_command.rs","lineNumber":299,"sourceCode":"    /// Project-mode load + compile through the bytecode cache — the same warm\n    /// flow as `baml run` (`run_command::load_and_compile`): whole-program hit\n    /// when nothing changed, per-file unit reuse on a dirty edit, full compile\n    /// otherwise. Pack shares run/check's exact cache key space, so a pack\n    /// right after a run (or a\n    /// re-pack) serves the identical `Program`. The packaged bytecode is\n    /// target-independent (the `--target` triple only selects the host binary\n    /// bytes), and emit determinism guarantees a reused image is byte-identical\n    /// to a fresh compile, so serving from cache never changes the artifact.\n    fn load_and_compile_project(\n        &self,\n        reporter: &Reporter,\n    ) -> Result<(ProjectDatabase, Program, bool)> {\n        let mut session = crate::project_session::ProjectSession::open(\n            self.from.as_deref(),\n            crate::project_session::CacheUse::ReadWrite,\n        )?;\n        if session.is_empty() {\n            anyhow::bail!(\"no `.baml` files found in {}\", session.root().display());\n        }\n        // Mirror `baml run`'s per-file format check: probe each source through\n        // the formatter and emit a single advisory if any file would change.\n        let needs_format_hint = session.needs_format_hint();\n\n        if let Some(program) = session.try_cached_program() {\n            crate::bytecode_cache::cache_debug(format_args!(\n                \"pack: bytecode cache hit — skipping compile\"\n            ));\n            return Ok((session.db, program, needs_format_hint));\n        }\n\n        // Seed the stdlib typed interface and prepare the per-file reuse plan —\n        // the same warm-database setup run/check/test use.\n        let warmth = session.warm_prep();\n        let (reuse_plan, stdlib_interface_hit) = (warmth.reuse_plan, warmth.stdlib_interface_hit);\n        let db = &session.db;\n        let package = session.package;","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/pack_command.rs#L281-L317","documentation":"load_and_compile_project opens a ProjectSession over the project directory; if the session reports no `.baml` sources at all (session.is_empty()), packing has nothing to compile and the CLI bails with the project root path in the message. `baml pack` only works on projects containing BAML source files.","triggerScenarios":"Running `baml pack` from (or with `--from` pointing to) a directory that contains zero `.baml` files.","commonSituations":"Running the command from the wrong working directory (repo root instead of the bamlsrc project, or vice versa); a misconfigured `--from` path; a checkout where BAML sources live elsewhere; typos in the project directory.","solutions":["cd into (or pass `--from` to) the directory that actually contains your `.baml` files.","Verify `.baml` files exist at the reported root: `ls <root>/**/*.baml`.","Ensure your project's baml source layout matches what the CLI expects (e.g. a bamlsrc/ directory) and re-run `baml pack`."],"exampleFix":"// before\nbaml pack   # run in repo root with no .baml files\n\n// after\ncd ./bamlsrc\nbaml pack -f MyFunction","handlingStrategy":"validation","validationCode":"# guard: ensure .baml files exist in the pack directory\nif ! find \"${PACK_DIR:-.}\" -name '*.baml' | grep -q .; then\n  echo \"no .baml files in ${PACK_DIR:-.}\" >&2; exit 2\nfi\nbaml pack --from \"$PACK_DIR\" -f \"$FUNC\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `baml pack` from the directory containing your `.baml` sources, or pass `--from` explicitly.","Verify source layout (e.g. bamlsrc/) in CI before invoking pack.","Don't confuse the repo root with the BAML project root."],"tags":["cli","missing-files","project","baml-pack"],"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"}