{"record":{"id":"806e0710b1ab7747","repo":"BoundaryML/baml","slug":"expected-from-to-be-a-baml-src-directory-but-it-is-not","errorCode":null,"errorMessage":"Expected --from '{}' to be a baml_src/ directory, but it is not","messagePattern":"Expected --from '(.+?)' to be a baml_src/ directory, but it is not","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/lib.rs","lineNumber":551,"sourceCode":"            async_runtime: rt.clone(),\n            publisher_env_vars: Some(publisher_env_vars),\n        };\n\n        Ok(runtime)\n    }\n\n    pub fn parse_baml_src_path(path: impl Into<PathBuf>) -> Result<PathBuf> {\n        let mut path: PathBuf = path.into();\n\n        if !path.exists() {\n            anyhow::bail!(\n                \"Expected --from '{}' to be a baml_src/ directory, but it does not exist\",\n                path.display()\n            );\n        }\n\n        if !path.is_dir() {\n            anyhow::bail!(\n                \"Expected --from '{}' to be a baml_src/ directory, but it is not\",\n                path.display()\n            );\n        }\n\n        if path.file_name() != Some(std::ffi::OsStr::new(\"baml_src\")) {\n            let contained = path.join(\"baml_src\");\n\n            if contained.exists() && contained.is_dir() {\n                path = contained;\n            } else {\n                anyhow::bail!(\n                    \"Expected --from '{}' to be a baml_src/ directory, but it is not\",\n                    path.display()\n                );\n            }\n        }\n","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/lib.rs#L533-L569","documentation":"Path validation in the runtime's project loader: the --from argument exists but is a regular file (or symlink to one), not a directory. The runtime requires the baml_src/ project directory because it globs *.baml files beneath it; passing a single .baml file path to --from trips this guard after the existence check passes.","triggerScenarios":"Passing a file path (e.g. ./baml_src/main.baml or a config file) where a directory is expected via --from or parse_baml_src_path.","commonSituations":"Tab-completion grabbing a file instead of the folder; passing a single .baml file expecting it to work; scripts interpolating the wrong variable.","solutions":["Point --from at the baml_src directory itself, not a file inside it","Use the directory path (e.g. ./baml_src) in scripts and commands","If the path is generated, assert path.is_dir() before invoking the runtime"],"exampleFix":"// before\nBamlRuntime::from_directory(\"./baml_src/greet.baml\")?;\n// after\nBamlRuntime::from_directory(\"./baml_src\")?;","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn validate_from(p: &str) -> Result<(), String> {\n    let path = Path::new(p);\n    if path.exists() && !path.is_dir() {\n        return Err(format!(\"--from '{}' must be a directory\", p));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the baml_src directory, never individual .baml files","Validate is_dir() in wrapper scripts before calling the runtime"],"tags":["rust","cli","filesystem","path"],"backgroundTag":"path-is-not-a-directory","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"}