BoundaryML/baml · error
positional `<TARGET>` is a function name, not a file path. F
Error message
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:
`baml pack --file {target} -f <NAME>`
What it means
validate_flags checks the positional `<TARGET>` with looks_like_path; if it resembles a file path, the command bails explaining that the positional is a function name, and that single-file sources must use `--file <path>` plus `-f <function-name>`.
Source
Thrown at baml_language/crates/baml_cli/src/pack_command.rs:236
);
Ok(crate::ExitCode::Success)
}
/// Validate flag combinations the clap-side `Args` derive can't catch.
fn validate_flags(&self) -> Result<()> {
if self.expression.is_some() {
anyhow::bail!(
"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 \View on GitHub (pinned to bd85ce9dee)
Solutions
- Pass just the function name: `baml pack myFunction`.
- For a single-file source, use `baml pack --file path/to_file.baml -f myFunction`.
- Keep project-rooted invocation (no path positional) and select targets via `-f`.
Example fix
// before baml pack ./baml_src/prompt.baml // after baml pack --file ./baml_src/prompt.baml -f myFunction
Defensive patterns
Strategy: validation
Validate before calling
# guard: positional must not look like a path TARGET="$1" case "$TARGET" in */*|*.baml) echo "use --file $TARGET -f <NAME>"; exit 1;; esac
Prevention
- Pass bare function names positionally to pack
- Use --file for single-file sources with -f for the function
- Avoid tab-completing .baml paths into the target slot
When it happens
Trigger: Run `baml pack some/path/to_file.baml` (or any path-looking positional) instead of a bare function name.
Common situations: Users familiar with `baml run <file.baml>` assuming pack takes a path, or tab-completing a .baml file into the positional slot.
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
- expression mode (`-e` / `--expression`) is not packageable;
- `--sdk-import-path` is only valid for the Go generator
- failed to initialize engine for resolution: {e:?}
- failed to serialize pack envelope: {e}
- `--file` and `--project` are mutually exclusive; `--file` al
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/6ed1d8441c6c45cb.
Report an issue: GitHub.