{"record":{"id":"42d9e4e935edefba","repo":"BoundaryML/baml","slug":"no-baml-files-found-in-playground-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/playground_command.rs","lineNumber":124,"sourceCode":"        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);\n    }\n\n    if let Some(dir) = discover_playground_dir()? {\n        return Ok(Some(dir));\n    }\n\n    anyhow::bail!(\n        \"could not find packaged playground assets. For local debugging, run \\\n         `pnpm --filter app-vscode-webview dev -- --host 127.0.0.1 --port 4000` \\","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/playground_command.rs#L106-L142","documentation":"The BAML CLI playground launcher (workspace_roots in playground_command.rs) loads the detected project and requires at least one `.baml` source file at the project root. If the resolved project directory contains no `.baml` files, it bails with this message naming the root path. This guards the playground from serving an empty project with nothing to render or compile.","triggerScenarios":"Running `baml playground` (or its callers like project-mode validation tests) in a directory that has a project marker (baml_src/ or manifest) but zero `.baml` files: `project.files.is_empty()` after `load_project_from(Some(&marked_root))`.","commonSituations":"A baml_src folder was created (e.g. `baml init` partially failed or files were moved/deleted); the `.baml` files live in a subdirectory outside the marked root; a rename from `.baml` to another extension; a fresh repo cloned without generated sources.","solutions":["Add at least one `.baml` file to the project root (or its baml_src directory).","Check the path printed in the error — that directory is where files must live; move your `.baml` files there.","If the project marker points at the wrong root, remove/relocate the stray baml_src directory or manifest.","Restore deleted or ignored `.baml` files (check .gitignore)."],"exampleFix":"// before: baml_src/ exists but is empty\nmkdir baml_src && baml playground  // fails\n\n// after: put sources in baml_src\nmv *.baml baml_src/\nbaml playground","handlingStrategy":"validation","validationCode":"# before running `baml playground`\nshopt -s nullglob\nfiles=(baml_src/*.baml)\nif [ ${#files[@]} -eq 0 ]; then echo \"No .baml files in baml_src/\"; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all BAML sources inside baml_src/ and never rename them to other extensions.","Run `baml validate` or list files in baml_src before launching the playground.","Ensure .gitignore does not exclude .baml files."],"tags":["cli","baml","playground","empty-project"],"backgroundTag":"empty-required-field","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"}