BoundaryML/baml · error

expression mode (`-e` / `--expression`) is not packageable;

Error message

expression mode (`-e` / `--expression`) is not packageable; pass a positional `<TARGET>` or `-f <NAME>` instead.

What it means

validate_flags rejects flag combinations the clap derive can't express. Expression mode (`-e`/`--expression`) evaluates an inline expression and is inherently not packageable, so `baml pack` bails if `--expression` is supplied.

Source

Thrown at baml_language/crates/baml_cli/src/pack_command.rs:225

                })?;
        }

        // Cargo's `Finished` is `<artifact-or-profile> [metadata]
        // in <elapsed>`. Mirror that: the artifact location is the
        // primary fact, with target name + triple in brackets so
        // the user can see what was packed and for which platform
        // without parsing an ambiguous arrow.
        reporter.finish(
            "Finished",
            format!("{} [{label}, {}]", output_path.display(), target_triple),
        );
        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() {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Drop `-e`/`--expression` and pass a positional function name: `baml pack <TARGET>`.
  2. Use `-f <NAME>` to select the function when sourcing a single file with `--file`.
  3. Use `baml run -e ...` for expression evaluation instead of pack.

Example fix

// before
baml pack -e "myFn(x)"
// after
baml pack myFn
Defensive patterns

Strategy: validation

Validate before calling

# guard before `baml pack ...`
case " $@ " in *" -e "*|*" --expression"*) echo "-e is not packageable"; exit 1;; esac

Prevention

When it happens

Trigger: Run `baml pack -e '<expression>'` (or `--expression ...`) with or without a positional target.

Common situations: Copy-pasting a `baml run -e ...` invocation and changing the verb to `pack` without adjusting 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


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/cb29c9c017797f8b. Report an issue: GitHub.