{"record":{"id":"9261faeafaee0533","repo":"BoundaryML/baml","slug":"is-not-a-file","errorCode":null,"errorMessage":"`{}` is not a file.","messagePattern":"`(.+?)` is not a file\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/project_load.rs","lineNumber":70,"sourceCode":"    }\n\n    let loaded = match reporter {\n        Some(reporter) => load_project_from_reporting(from, reporter)?,\n        None => load_project_from(from)?,\n    };\n    let root = loaded.root().to_path_buf();\n    Ok(SourceLocation::Project {\n        root,\n        files: loaded.files,\n    })\n}\n\npub(crate) fn resolve_standalone_file(file_path: &Path) -> Result<PathBuf> {\n    let display = file_path.display().to_string();\n    let canonical =\n        std::fs::canonicalize(file_path).with_context(|| format!(\"file not found: {display}\"))?;\n    if !canonical.is_file() {\n        anyhow::bail!(\"`{}` is not a file.\", canonical.display());\n    }\n    if canonical.extension().and_then(|ext| ext.to_str()) != Some(\"baml\") {\n        anyhow::bail!(\n            \"`{}` is not a BAML source file. Use a `.baml` file with `--file`.\",\n            canonical.display()\n        );\n    }\n    Ok(canonical)\n}\n\n/// Resolve `from` (or cwd when omitted) and load all discovered `.baml` files\n/// into a fresh\n/// [`ProjectDatabase`]. Returns the database, the canonical project root,\n/// and the list of loaded files. Used by the build/execute commands\n/// (`run`/`test`/`generate`/`pack`).\n///\n/// **`baml.toml` is opt-in.** A directory is a BAML project if it has\n/// *either* a `baml.toml` *or* a `baml_src/` directory — `baml.toml` is","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/project_load.rs#L52-L88","documentation":"resolve_standalone_file canonicalizes the --file path and verifies it is a regular file. If the path exists (canonicalize succeeded) but is a directory or special file (not `is_file()`), the CLI bails with this message. It catches the common mistake of passing a directory to --file.","triggerScenarios":"Calling --file with a path that canonicalizes successfully but is a directory (e.g. `--file ./baml_src`) or a socket/fifo, from load_standalone, resolve_source_location, or load_and_compile_standalone.","commonSituations":"Pointing --file at the baml_src directory instead of a file inside it; a trailing-slash directory path; expecting --file to accept project roots like --project does; a broken symlink resolving to a directory.","solutions":["Pass a path to an actual file, not a directory: `--file baml_src/main.baml`.","If you intended to load a whole directory, use --project instead of --file.","Check the path printed in the error and confirm with `ls -la` that it is a regular file.","Fix broken symlinks pointing at directories."],"exampleFix":"// before\nbaml dev --file ./baml_src\n\n// after\nbaml dev --file ./baml_src/main.baml","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nF=\"$1\"\nif [ -d \"$F\" ] || [ ! -f \"$F\" ]; then echo \"--file needs a regular file, got: $F\"; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a concrete .baml file path to --file, never a directory.","Use --project for directories.","Verify with `test -f` in scripts before invoking the CLI."],"tags":["cli","baml","file","wrong-type"],"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"}