{"record":{"id":"491ddc2d1ebe624a","repo":"BoundaryML/baml","slug":"doesn-t-look-like-it-belongs-to-a-baml-project-no-baml-toml-491ddc","errorCode":null,"errorMessage":"`{}` doesn't look like it belongs to a BAML project — no `baml.toml` and no `baml_src/` directory found in it or its ancestors.\nadd a `baml_src/` directory with your `.baml` files, run `baml init`, or pass `--project <DIR>` to load an explicit source directory.","messagePattern":"`(.+?)` doesn't look like it belongs to a BAML project — no `baml\\.toml` and no `baml_src/` directory found in it or its ancestors\\.\nadd a `baml_src/` directory with your `\\.baml` files, run `baml init`, or pass `--project <DIR>` to load an explicit source directory\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/project_load.rs","lineNumber":370,"sourceCode":"/// hit the database (and everything downstream of it: typecheck, emit) is\n/// skipped entirely; on a miss [`build_db_from_sources`] reuses these\n/// already-read contents instead of re-reading from disk.\npub(crate) struct ResolvedProject {\n    /// Canonical settings root: the directory holding the effective\n    /// `baml.toml`, or the explicit standalone source root without a manifest.\n    pub root: PathBuf,\n    /// `baml.toml` content when present (already validated).\n    pub manifest: Option<String>,\n    /// Discovered `.baml` files with contents, in discovery (sorted) order.\n    pub files: Vec<(PathBuf, String)>,\n}\n\n/// Resolve the project root, validate the manifest, and read every source\n/// file into memory. The strict-path front half of [`load_project_from`].\npub(crate) fn resolve_project_sources(from: Option<&Path>) -> Result<ResolvedProject> {\n    let search_start = resolve_search_start(from)?;\n    let Some(layout) = resolve_project_layout(from)? else {\n        anyhow::bail!(\n            \"`{}` doesn't look like it belongs to a BAML project — no `baml.toml` \\\n             and no `baml_src/` directory found in it or its ancestors.\\n\\\n             add a `baml_src/` directory with your `.baml` files, run `baml init`, \\\n             or pass `--project <DIR>` to load an explicit source directory.\",\n            search_start.display()\n        );\n    };\n\n    let toml_path = layout.root.join(BAML_TOML);\n\n    // Manifest validation, Cargo-style: when a `baml.toml` is present it must\n    // be valid (`[package].name` mandatory). Failing here — before any source\n    // discovery or compilation — gives the same fast feedback as a malformed\n    // `Cargo.toml`, rather than crashing several seconds in when a packaging\n    // verb tries to use the name. A manifest-less `baml_src/` project skips\n    // this: `baml.toml` is opt-in.\n    let manifest = if toml_path.exists() {\n        let content = std::fs::read_to_string(&toml_path)","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/project_load.rs#L352-L388","documentation":"BAML CLI could not locate a BAML project root from the given directory: neither a `baml.toml` manifest nor a `baml_src/` directory exists in the directory or any ancestor. `resolve_project_sources` refuses to load sources because there is nothing to compile. This guards against silently compiling an empty or wrong project.","triggerScenarios":"Calling `resolve_project_sources(from)` (via `load_project_from_inner`, `open`, or `--project <DIR>`) when the resolved search start directory contains no `baml.toml` and no `baml_src/` directory anywhere up its ancestor chain.","commonSituations":"Running `baml` commands outside a project; typo'd `--project` path; project initialized without `baml init`; renamed/deleted `baml_src/` directory; running from a subdirectory of an unrelated folder.","solutions":["Run `baml init` in the directory to create a `baml_src/` with sample `.baml` files","Create a `baml_src/` directory containing your `.baml` files in the project root","Pass `--project <DIR>` pointing at a directory that contains `baml.toml` or `baml_src/`","cd into the actual BAML project directory before running the command"],"exampleFix":"// before\nbaml generate --project ./wrong-dir\n// after\nbaml generate --project ./my-baml-project  # contains baml.toml and baml_src/","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nfunction isBamlProject(dir) {\n  let cur = require('path').resolve(dir);\n  while (true) {\n    if (fs.existsSync(require('path').join(cur, 'baml.toml')) ||\n        fs.existsSync(require('path').join(cur, 'baml_src'))) return true;\n    const parent = require('path').dirname(cur);\n    if (parent === cur) return false;\n    cur = parent;\n  }\n}\nif (!isBamlProject('./')) throw new Error('not a BAML project: run baml init or pass --project');","typeGuard":null,"tryCatchPattern":"try { await baml.loadProject(dir); } catch (e) { if (String(e).includes('baml_src')) { console.error('Run `baml init` or pass --project <DIR>'); process.exit(1); } throw e; }","preventionTips":["Always run `baml init` before CLI commands in a new directory","Invoke CLI commands from the project root or a subdirectory of it","Verify `baml_src/` exists with `ls baml_src` before running","Use `--project <DIR>` explicitly in scripts/CI instead of relying on cwd"],"tags":["cli","project-resolution","baml"],"backgroundTag":"config-file-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}