{"record":{"id":"ff803b76860bfa9c","repo":"BoundaryML/baml","slug":"doesn-t-look-like-it-belongs-to-a-baml-project-no-baml-toml-ff803b","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.","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\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/project_load.rs","lineNumber":487,"sourceCode":"pub(crate) fn validate_baml_toml(toml_path: &Path) -> Result<String> {\n    let content = std::fs::read_to_string(toml_path)\n        .with_context(|| format!(\"failed to read {}\", toml_path.display()))?;\n    let manifest = baml_db::manifest::parse(&content)\n        .with_context(|| format!(\"failed to parse {}\", toml_path.display()))?;\n    baml_db::manifest::reject_stdlib_only_tables(&manifest, toml_path)?;\n    Ok(baml_db::manifest::package_name(&manifest, toml_path)?)\n}\n\n/// Resolve the project's name for output-artifact naming (used by `baml\n/// pack`). Prefers `[package].name` from `<root>/baml.toml` when a manifest\n/// is present (guaranteed valid for any path we've loaded as a project).\n/// For a manifest-less `baml_src/` project, falls back to the project\n/// directory's name — the way `cargo` names a target after its directory\n/// when no explicit name is given.\npub(crate) fn resolve_project_name(from: Option<&Path>) -> Result<String> {\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            search_start.display()\n        );\n    };\n    let toml_path = layout.root.join(BAML_TOML);\n    if toml_path.exists() {\n        return validate_baml_toml(&toml_path);\n    }\n    layout\n        .root\n        .file_name()\n        .and_then(|name| name.to_str())\n        .map(str::to_string)\n        .ok_or_else(|| {\n            anyhow::anyhow!(\n                \"could not derive a project name from `{}`; pass `-o <PATH>` to name the output.\",\n                layout.root.display()","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/project_load.rs#L469-L505","documentation":"Same root-cause as the source-resolution failure: `resolve_project_name` needs a valid project layout (a `baml.toml` or `baml_src/` in the directory or an ancestor) to derive a project name, and none was found. The CLI bails rather than guessing a name for a non-project directory.","triggerScenarios":"Calling `resolve_project_name(from)` when `resolve_project_layout` returns None — no `baml.toml` and no `baml_src/` at or above the search start path.","commonSituations":"Same as project-source resolution failures: invoking the CLI outside a BAML project, bad `--project` path, or a project whose manifest/src dir was removed.","solutions":["Add a `baml.toml` with an explicit project name to the project root","Create the `baml_src/` directory so the layout resolves and the directory name can be used","Run `baml init` to scaffold a proper project","Pass `--project <DIR>` targeting a real BAML project"],"exampleFix":"// before (empty dir)\n$ baml open\n// after\n$ baml init   # creates baml_src/ so the project name resolves","handlingStrategy":"validation","validationCode":"const fs = require('fs'), path = require('path');\nfunction hasBamlLayout(dir) {\n  let cur = path.resolve(dir);\n  while (true) {\n    if (fs.existsSync(path.join(cur, 'baml.toml')) || fs.existsSync(path.join(cur, 'baml_src'))) return true;\n    const parent = path.dirname(cur);\n    if (parent === cur) return false;\n    cur = parent;\n  }\n}\nif (!hasBamlLayout(process.cwd())) throw new Error('no baml.toml or baml_src/ found; project name cannot be resolved');","typeGuard":null,"tryCatchPattern":"try { const name = baml.resolveProjectName(dir); } catch (e) { if (String(e).includes(\"doesn't look like it belongs to a BAML project\")) { console.error('Initialize the project first: baml init'); } throw e; }","preventionTips":["Add a `baml.toml` with an explicit name to avoid name derivation","Run commands inside a real BAML project","Validate the project layout in CI before invoking name-dependent commands"],"tags":["cli","project-resolution","baml"],"backgroundTag":"missing-required-config","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"}