BoundaryML/baml · error
positional `<TARGET>` and `-f/--function` are mutually exclu
Error message
positional `<TARGET>` and `-f/--function` are mutually exclusive — use one or the other (positional packs a single-entry binary; `-f` produces a subcommand binary).
What it means
This error comes from `baml pack` argument validation in validate_flags. The positional `<TARGET>` argument and the `-f/--function` flag are two mutually exclusive ways to select what to pack: the positional packs a single-entry binary, while `-f` produces a subcommand binary. Supplying both is ambiguous, so the CLI refuses to run.
Source
Thrown at baml_language/crates/baml_cli/src/pack_command.rs:244
"expression mode (`-e` / `--expression`) is not packageable; \
pass a positional `<TARGET>` or `-f <NAME>` instead."
);
}
// `--file` and `--project` both name a source location. Reject the
// combination up front instead of silently preferring one. Same rule
// as `baml run`.
validate_file_project_flags(self.file.as_deref(), self.from.as_deref())?;
if let Some(target) = self.target.as_deref() {
if looks_like_path(target) {
anyhow::bail!(
"positional `<TARGET>` is a function name, not a file path. \
For a single-file source, use `--file {target}` and pass the \
function via `-f <NAME>`. For example:\n\
\n `baml pack --file {target} -f <NAME>`\n",
);
}
if !self.functions.is_empty() {
anyhow::bail!(
"positional `<TARGET>` and `-f/--function` are mutually exclusive — \
use one or the other (positional packs a single-entry binary; \
`-f` produces a subcommand binary)."
);
}
}
if self.target.is_none() && self.functions.is_empty() {
anyhow::bail!(
"no target specified. Pass a positional `<TARGET>` to pack one \
function as the binary's only entry point, or one or more \
`-f <NAME>` flags to pack a subcommand binary."
);
}
Ok(())
}
fn resolved_target_triple(&self) -> Result<&str> {
match self.target_triple.as_deref() {View on GitHub (pinned to bd85ce9dee)
Solutions
- Remove the `-f/--function` flags if you want a single-entry binary from the positional `<TARGET>` (or `--file <PATH>`).
- Remove the positional `<TARGET>` (or `--file`) and keep `-f <NAME>` flags if you want a subcommand binary.
- Run `baml pack --help` to review which argument style you intend and keep exactly one.
Example fix
// before baml pack MyFunction -f OtherFunction // after (single-entry binary) baml pack MyFunction // or (subcommand binary) baml pack -f MyFunction -f OtherFunction
Defensive patterns
Strategy: validation
Validate before calling
// shell guard before invoking the CLI if [ -n "$TARGET" ] && [ -n "$FUNCTIONS" ]; then echo "pass either positional TARGET or -f flags, not both" >&2; exit 2 fi baml pack $TARGET $FUNCTIONS
Prevention
- Decide upfront whether you want a single-entry binary (positional) or a subcommand binary (-f) and use only that style per invocation.
- Wrap `baml pack` invocations in scripts with explicitly separated argument groups.
- Review `baml pack --help` before composing new invocations.
When it happens
Trigger: Running `baml pack` with both a positional target (or `--file <PATH>`) and one or more `-f/--function` flags, e.g. `baml pack my_target -f MyFunc`.
Common situations: Developers switching from single-entry packing to subcommand packing (or vice versa) leave the old argument in place; shell scripts grow an extra flag; users copy a documented `-f` example but keep a positional from autocomplete or muscle memory.
Related errors
- usage: baml self-update unexpected arguments: {}
- no target specified. Pass a positional `<TARGET>` to pack on
- compilation failed: {e:?}
- no `.baml` files found in {}
- two targets share subcommand name `{}` (`{}` and `{}`). Subc
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/20d86e0406cd5b4f.
Report an issue: GitHub.