BoundaryML/baml · error
`-e` is not compatible with `--file`. Expression mode…
Error message
`-e` is not compatible with `--file`. Expression mode evaluates inline source; remove one of the two.
What it means
`baml run -e` evaluates inline source, while `--file` changes which source files are loaded. The CLI rejects this combination up front because expression mode short-circuits project/file loading, so `--file` would silently do nothing.
Solutions
- Remove the `--file <path>` argument and keep `-e <expr>`
- Remove the `-e <expr>` argument and rely on `--file` plus a function target
Example fix
// before baml run --file baml_src/main.baml -e 'test()' // after baml run -e 'test()'
Defensive patterns
Strategy: validation
Validate before calling
if (args.includes('-e') && (args.includes('--file') || args.some(a => a.startsWith('--file=')))) { throw new Error('Remove either -e or --file'); } Prevention
- Never combine -e with --file
- Build CLI invocations from flag groups (expression vs file) that are known mutually exclusive
- Read baml run --help before composing flags
When it happens
Trigger: Invoking `baml run` with both an expression passed via `-e <expr>` and a file passed via `--file <path>`.
Common situations: A developer combining an example expression snippet with an existing `--file` invocation, or scripting a command that templated both flags.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- `-e` is not compatible with `--list`. Expression mode…
- are mutually exclusive dispatch modes — pick one.
- {bail_context}
- Cannot generate HIR/bytecode due to validation errors
- compilation failed
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/285958c1414b0379.
Report an issue: GitHub.
Appendix: source
Thrown at baml_language/crates/baml_cli/src/run_command.rs:419
if used.len() > 1 {
anyhow::bail!(
"{} are mutually exclusive dispatch modes — pick one.",
used.join(" and ")
);
}
// `--file` is the standalone-source alternative to `--project`. Both
// pointing at sources would be ambiguous (which one wins?), so
// reject an explicit combination up front.
validate_file_project_flags(self.file.as_deref(), self.from.as_deref())?;
// Expression mode short-circuits before reaching project / file
// loading, so combining `-e` with surfaces that change *what* is
// loaded silently does nothing. Reject up front to avoid the
// footgun.
if self.expression.is_some() {
if self.file.is_some() {
anyhow::bail!(
"`-e` is not compatible with `--file`. Expression mode \
evaluates inline source; remove one of the two."
);
}
if self.list {
anyhow::bail!(
"`-e` is not compatible with `--list`. Expression mode \
evaluates an expression; `--list` enumerates targets — \
pick one."
);
}
}
if let Some(expr_source) = &self.expression {
// `-e -` reads stdin / `-e @file` reads file. Load once so
// the engine compile and `argv[1]` see the same text.
let expr_body = load_expression_source(expr_source)?;
return self.run_expression(&expr_body, reporter);View on GitHub (pinned to bd85ce9dee)