BoundaryML/baml · error
`{}` is not a file.
Error message
`{}` is not a file. What it means
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.
Source
Thrown at baml_language/crates/baml_cli/src/project_load.rs:70
}
let loaded = match reporter {
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` isView on GitHub (pinned to bd85ce9dee)
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.
Example fix
// before baml dev --file ./baml_src // after baml dev --file ./baml_src/main.baml
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash F="$1" if [ -d "$F" ] || [ ! -f "$F" ]; then echo "--file needs a regular file, got: $F"; exit 1; fi
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- `{}` is not a BAML source file. Use a `.baml` file with `--f
- 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/9261faeafaee0533.
Report an issue: GitHub.