BoundaryML/baml · error
`{}` is not a BAML source file. Use a `.baml` file with `--f
Error message
`{}` is not a BAML source file. Use a `.baml` file with `--file`. What it means
After confirming the --file path is a regular file, resolve_standalone_file checks its extension is `.baml`. A non-`.baml` file is rejected because --file only accepts BAML source files. This prevents compiling config files, generated code, or unrelated sources as BAML.
Source
Thrown at baml_language/crates/baml_cli/src/project_load.rs:73
Some(reporter) => load_project_from_reporting(from, reporter)?,
None => load_project_from(from)?,
};
let root = loaded.root().to_path_buf();
Ok(SourceLocation::Project {
root,
files: loaded.files,
})
}
pub(crate) fn resolve_standalone_file(file_path: &Path) -> Result<PathBuf> {
let display = file_path.display().to_string();
let canonical =
std::fs::canonicalize(file_path).with_context(|| format!("file not found: {display}"))?;
if !canonical.is_file() {
anyhow::bail!("`{}` is not a file.", canonical.display());
}
if canonical.extension().and_then(|ext| ext.to_str()) != Some("baml") {
anyhow::bail!(
"`{}` is not a BAML source file. Use a `.baml` file with `--file`.",
canonical.display()
);
}
Ok(canonical)
}
/// Resolve `from` (or cwd when omitted) and load all discovered `.baml` files
/// into a fresh
/// [`ProjectDatabase`]. Returns the database, the canonical project root,
/// and the list of loaded files. Used by the build/execute commands
/// (`run`/`test`/`generate`/`pack`).
///
/// **`baml.toml` is opt-in.** A directory is a BAML project if it has
/// *either* a `baml.toml` *or* a `baml_src/` directory — `baml.toml` is
/// only needed when you actually use one of its features (dependencies,
/// version locks, `[scripts]`, multiple packages). The two cases:
///View on GitHub (pinned to bd85ce9dee)
Solutions
- Rename the file to have a `.baml` extension if it truly is BAML source.
- Point --file at the actual `.baml` source file (e.g. baml_src/main.baml), not generated client code or config.
- If you meant a whole project/config directory, use --project instead.
- Check the canonical path printed in the error to identify which file was rejected.
Example fix
// before baml dev --file ./generated_baml_client.py // after baml dev --file ./baml_src/main.baml
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash F="$1" case "$F" in *.baml) ;; *) echo "--file requires a .baml source file, got: $F"; exit 1 ;; esac
Prevention
- Only pass files ending in .baml to --file.
- Don't confuse generated client code or config files with BAML sources.
- Name new BAML source files with the .baml extension from the start.
When it happens
Trigger: Passing a file whose canonical path extension is not `baml` (e.g. .txt, .json, main.py, generated .ts) to --file via load_standalone, resolve_source_location, or load_and_compile_standalone.
Common situations: Passing a generated client file (e.g. baml_client/.../main.py) instead of the source; passing baml.config or a manifest file; files renamed to .bak/.txt; forgetting the .baml extension on a newly created source file.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- `{}` is not a file.
- compilation failed: {e:?}
- no `.baml` files found in {}
- could not find packaged playground assets. For local debuggi
- `--file` and `--project` are mutually exclusive; `--file` al
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/51e78e816cf64d5c.
Report an issue: GitHub.