{"record":{"id":"a0fa63f16a662926","repo":"BoundaryML/baml","slug":"doesn-t-look-like-it-belongs-to-a-baml-project-no-baml-toml","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/playground_command.rs","lineNumber":115,"sourceCode":"    false\n}\n\nfn workspace_roots(from: Option<&Path>, file: Option<&Path>) -> Result<Vec<PathBuf>> {\n    // The playground's LSP currently discovers projects from marker-bearing\n    // workspace roots. Unlike the compile/run commands, it cannot yet carry a\n    // settings root and a disjoint source root as one project, so retain its\n    // marker requirement instead of accepting a root it would silently ignore.\n    if file.is_some() {\n        return match resolve_source_location(from, file, None)? {\n            SourceLocation::StandaloneFile { file, .. } => Ok(vec![file]),\n            SourceLocation::Project { .. } => unreachable!(\"file mode resolved as a project\"),\n        };\n    }\n\n    let search_start = resolve_project_search_start(from)\n        .with_context(|| \"could not resolve playground project search path\")?;\n    let Some(marked_root) = find_baml_project_root(&search_start) 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 project = load_project_from(Some(&marked_root))?;\n    let root = project.root().to_path_buf();\n    if project.files.is_empty() {\n        anyhow::bail!(\"no `.baml` files found in {}\", root.display());\n    }\n    Ok(vec![root])\n}\n\nfn resolve_playground_assets() -> Result<Option<PathBuf>> {\n    if std::env::var_os(\"BAML_PLAYGROUND_DEV_PORT\").is_some()\n        || std::env::var_os(\"BAML_PLAYGROUND_DIR\").is_some()\n    {\n        return Ok(None);","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/playground_command.rs#L97-L133","documentation":"`workspace_roots` in the playground command resolves the BAML project root by walking up from a starting path looking for a `baml.toml` manifest or a `baml_src/` directory. If `find_baml_project_root` finds neither in the start directory nor any ancestor, it bails with this message. It's the playground's way of refusing to run outside any recognizable BAML project.","triggerScenarios":"Running the playground (`run`) or tests like `project_mode_errors_without_project_marker` from/pointing at a directory that contains no `baml.toml` and no `baml_src/` anywhere in itself or its ancestors — e.g. passing a standalone file path outside a project or launching from $HOME/tmp.","commonSituations":"Launching the playground from the wrong working directory (repo root instead of the BAML package, or an unrelated folder); the project lacks `baml.toml` and its source dir isn't named `baml_src/`; pointing `--file` at a standalone `.baml` file kept outside any project tree.","solutions":["cd into the BAML project directory (or a subdirectory of it) before launching the playground.","Add a `baml.toml` manifest at the project root, or rename/ensure the source directory is `baml_src/`, so the marker walk-up finds it.","If using a standalone file, place it inside a directory with a `baml.toml` or `baml_src/` marker (or an ancestor of it).","Verify with `ls baml.toml baml_src` from your current directory and each ancestor to confirm a marker exists on the path."],"exampleFix":"// before: running playground from an unrelated dir with sources elsewhere\n$ cd ~ && baml-cli playground\n// after: create the marker at the project root, then run from the project\n$ cd ~/my-project && mkdir -p baml_src && baml-cli playground","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nfunction findBamlRoot(start: string): string | null {\n  let dir = path.resolve(start);\n  while (true) {\n    if (fs.existsSync(path.join(dir, 'baml.toml')) || fs.existsSync(path.join(dir, 'baml_src'))) return dir;\n    const parent = path.dirname(dir);\n    if (parent === dir) return null;\n    dir = parent;\n  }\n}\n// call findBamlRoot(process.cwd()) before launching the playground","typeGuard":"function isBamlProjectRoot(dir: string): boolean {\n  return fs.existsSync(path.join(dir, 'baml.toml')) || fs.existsSync(path.join(dir, 'baml_src'));\n}","tryCatchPattern":"try {\n  const roots = await workspace_roots(from);\n  startPlayground(roots);\n} catch (e) {\n  if (String(e).includes('baml.toml')) {\n    console.error('No BAML project found: add baml.toml or baml_src/ at your project root, then rerun.');\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Always launch the playground from inside a BAML project (a directory containing baml.toml or baml_src/).","Keep the standard `baml_src/` directory name so marker detection works.","Keep a `baml.toml` at every project root even for minimal setups.","Don't keep standalone .baml files outside any marked project tree if you use the playground on them."],"tags":["rust","cli","playground","project-root","filesystem"],"backgroundTag":"directory-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"}