BoundaryML/baml · error

`-e` is not compatible with `--list`. Expression mode…

Error message

`-e` is not compatible with `--list`. Expression mode evaluates an expression; `--list` enumerates targets — pick one.

What it means

Flag-compatibility guard in the run verb: `-e` (expression mode) was combined with `--list`. Expression mode evaluates a single expression and short-circuits before project loading, while --list enumerates targets from a loaded project — combining them would silently ignore one. The check is done up front to avoid the footgun.

Solutions

  1. Drop `--list` and keep `-e <expr>`
  2. Drop `-e` and run with `--list` to enumerate targets

Example fix

// before
baml run --list -e 'test()'
// after
baml run -e 'test()'
Defensive patterns

Strategy: validation

Validate before calling

if (args.includes('-e') && args.includes('--list')) { throw new Error('Remove either -e or --list'); }

Prevention

When it happens

Trigger: Invoking `baml run` with both `-e <expr>` and the `--list` flag.

Common situations: A developer trying to list targets while also evaluating an expression, e.g. composing flags from a generic script template.

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/ca0ab49c540acd6f. Report an issue: GitHub.

Appendix: source

Thrown at baml_language/crates/baml_cli/src/run_command.rs:425

        // `--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);
        }

        // `--list` short-circuit doesn't need a resolved target; load
        // the project and print before we get to dispatch.
        if self.list {
            let bootstrap_argv = vec![

View on GitHub (pinned to bd85ce9dee)