BoundaryML/baml · error
toolchain path is a directory: {}{origin} Point at the {} bi
Error message
toolchain path is a directory: {}{origin}
Point at the {} binary, e.g. {} What it means
verify_path_toolchain validates that a `--path` toolchain selector points at a runnable binary, not a directory. When the given path is a directory (commonly the toolchain root itself), the wrapper rejects it and hints at the correct binary location (root/bin/baml). This guards against users pointing at the extracted distribution folder instead of the executable inside it.
Source
Thrown at baml_language/crates/baml/src/main.rs:918
(Ok(current), Ok(cli)) => current == cli,
_ => current == cli,
};
if same {
return Err(anyhow!(
"toolchain path points at the baml wrapper itself: {}{origin}\nPoint at the {} binary instead, which is built alongside it.",
cli.display(),
cli_exe_name()
));
}
Ok(())
}
/// Check that a path selector points at something runnable. `origin` is a
/// pre-formatted `set by ...` line, or empty when the path came straight from
/// the command line and needs no attribution.
fn verify_path_toolchain(cli: &Path, origin: &str) -> Result<()> {
if cli.is_dir() {
return Err(anyhow!(
"toolchain path is a directory: {}{origin}\nPoint at the {} binary, e.g. {}",
cli.display(),
cli_exe_name(),
cli.join("bin").join(cli_exe_name()).display()
));
}
if !cli.exists() {
return Err(anyhow!(
"toolchain binary not found: {}{origin}",
cli.display()
));
}
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let mode = fs::metadata(cli)
.with_context(|| format!("failed to read {}", cli.display()))?
.permissions()View on GitHub (pinned to bd85ce9dee)
Solutions
- Point the path selector at the binary itself, e.g. <toolchain-root>/bin/baml, not the root directory.
- If the path was set via an env var, update it: export BAML_TOOLCHAIN_PATH=/path/to/toolchain/bin/baml.
- Run `baml toolchain status` to see the current selector and its origin, then correct it with `baml toolchain use <version>` if a managed toolchain was intended.
Example fix
// before baml --path ~/toolchains/0.210.0 --version // after baml --path ~/toolchains/0.210.0/bin/baml --version
Defensive patterns
Strategy: validation
Validate before calling
const p = process.env.BAML_TOOLCHAIN_PATH!;
const st = fs.statSync(p);
if (st.isDirectory()) throw new Error(`Point BAML_TOOLCHAIN_PATH at the binary, e.g. ${p}/bin/baml`); Type guard
function isExecutableFilePath(p: string): boolean {
try { return fs.statSync(p).isFile(); } catch { return false; }
} Prevention
- Always append /bin/baml when pointing at a toolchain root directory.
- Validate toolchain paths in scripts with a stat check before invoking baml.
- Prefer managed toolchains (`baml toolchain use <version>`) over raw --path overrides.
When it happens
Trigger: Calling any command that resolves a path-based toolchain (print_version, exec_path_toolchain, prepare_toolchain_selector, status_toolchain) with a path selector where `cli.is_dir()` is true — i.e. the user passed a directory such as the toolchain root.
Common situations: Setting BAML_TOOLCHAIN_PATH (or --path flag) to the extracted toolchain directory or a home/toolchains/<version> folder instead of the bin/baml binary; autocompletion selecting a directory; scripts that resolve a version directory and forget to append bin/baml.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- toolchain binary not found: {}{origin}
- usage: baml toolchain install <canary|nightly|version>
- usage: baml toolchain use <canary|nightly|version|path>
- usage: baml toolchain pin <canary|nightly|version|path>
- usage: baml toolchain pin <canary|nightly|version|path> unex
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/569ee6baffdfc627.
Report an issue: GitHub.