BoundaryML/baml · error
cannot derive an output name from `{}`; pass `-o <PATH>` to
Error message
cannot derive an output name from `{}`; pass `-o <PATH>` to name the output. What it means
resolve_output_basename derives the output file name for the packed binary. For single-file `--file` packs it uses the file stem; if the path has no usable UTF-8 stem (e.g. a nameless/odd path), and no `-o <PATH>` was supplied, the CLI cannot name the output and bails, telling you to pass `-o` explicitly.
Source
Thrown at baml_language/crates/baml_cli/src/pack_command.rs:433
/// `foo`). `baml.toml` isn't consulted — single-file packs are
/// intentionally hermetic.
/// - Project mode: `[package].name` from `<from>/baml.toml` when a
/// manifest is present, else the project directory name for a
/// manifest-less `baml_src/` project (see
/// [`crate::project_load::resolve_project_name`]).
fn resolve_output_basename(&self) -> Result<String> {
if let Some(file) = self.file.as_deref() {
// Keep `--file` hermetic: derive the name from the file path
// alone, never from `--from`/project markers. A path with no
// usable file-name component (no stem, e.g. `..`, or a non-UTF-8
// name) can't be named automatically — bail rather than leak the
// cwd's project context into a single-file pack.
return file
.file_stem()
.and_then(|s| s.to_str())
.map(str::to_string)
.ok_or_else(|| {
anyhow::anyhow!(
"cannot derive an output name from `{}`; pass `-o <PATH>` to name the output.",
file.display()
)
});
}
crate::project_load::resolve_project_name(self.from.as_deref())
}
}
/// Resolve a single function-name string against the engine; returns
/// canonical qualified/display/subcommand-name triple.
fn resolve_one(engine: &BexEngine, func: &str) -> Result<ResolvedPackTarget> {
if !engine.function_exists(func) {
let suggestions = function_suggestions(engine, func);
if suggestions.is_empty() {
anyhow::bail!(
"function `{func}` not found. Use `baml run --list` to see \
available targets."View on GitHub (pinned to bd85ce9dee)
Solutions
- Pass `-o <PATH>` to name the output explicitly, e.g. `baml pack --file ./weird\ name.baml -o out`.
- Rename the source file so it has a normal UTF-8 stem, then re-run without `-o`.
- For project packs, ensure the project root resolves to a valid project name (resolve_project_name) or supply `-o`.
Example fix
// before baml pack --file "$(printf 'weird\xff.baml')" // after baml pack --file ./my_func.baml -o my_func_bin
Defensive patterns
Strategy: validation
Validate before calling
# always supply -o when the input path is not a simple UTF-8 name
case "$FILE" in
*[![:print:]]*|"") echo "use -o to name output" >&2; OUT=(-o packed_bin) ;;
*) OUT=() ;;
esac
baml pack --file "$FILE" "${OUT[@]}" Prevention
- Always pass `-o` in scripted/automated pack invocations.
- Keep source filenames simple ASCII stems.
- Validate file paths coming from other tools before packing.
When it happens
Trigger: Running `baml pack --file <path>` where `<path>` yields no valid file_stem (non-UTF-8 or empty stem) without specifying `-o`.
Common situations: Programmatically constructed paths with unusual characters or non-UTF-8 bytes; piping a path from another tool on systems with odd filenames; forgetting `-o` on scripted pack invocations.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- positional `<TARGET>` and `-f/--function` are mutually exclu
- 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/506745b195e8440a.
Report an issue: GitHub.