{"record":{"id":"ca0ab49c540acd6f","repo":"BoundaryML/baml","slug":"e-is-not-compatible-with-list-expression-mode-evaluates-an","errorCode":null,"errorMessage":"`-e` is not compatible with `--list`. Expression mode evaluates an expression; `--list` enumerates targets — pick one.","messagePattern":"`-e` is not compatible with `--list`\\. Expression mode evaluates an expression; `--list` enumerates targets — pick one\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":425,"sourceCode":"\n        // `--file` is the standalone-source alternative to `--project`. Both\n        // pointing at sources would be ambiguous (which one wins?), so\n        // reject an explicit combination up front.\n        validate_file_project_flags(self.file.as_deref(), self.from.as_deref())?;\n\n        // Expression mode short-circuits before reaching project / file\n        // loading, so combining `-e` with surfaces that change *what* is\n        // loaded silently does nothing. Reject up front to avoid the\n        // footgun.\n        if self.expression.is_some() {\n            if self.file.is_some() {\n                anyhow::bail!(\n                    \"`-e` is not compatible with `--file`. Expression mode \\\n                     evaluates inline source; remove one of the two.\"\n                );\n            }\n            if self.list {\n                anyhow::bail!(\n                    \"`-e` is not compatible with `--list`. Expression mode \\\n                     evaluates an expression; `--list` enumerates targets — \\\n                     pick one.\"\n                );\n            }\n        }\n\n        if let Some(expr_source) = &self.expression {\n            // `-e -` reads stdin / `-e @file` reads file. Load once so\n            // the engine compile and `argv[1]` see the same text.\n            let expr_body = load_expression_source(expr_source)?;\n            return self.run_expression(&expr_body, reporter);\n        }\n\n        // `--list` short-circuit doesn't need a resolved target; load\n        // the project and print before we get to dispatch.\n        if self.list {\n            let bootstrap_argv = vec![","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L407-L443","documentation":"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.","triggerScenarios":"Invoking `baml run` with both `-e <expr>` and the `--list` flag.","commonSituations":"A developer trying to list targets while also evaluating an expression, e.g. composing flags from a generic script template.","solutions":["Drop `--list` and keep `-e <expr>`","Drop `-e` and run with `--list` to enumerate targets"],"exampleFix":"// before\nbaml run --list -e 'test()'\n// after\nbaml run -e 'test()'","handlingStrategy":"validation","validationCode":"if (args.includes('-e') && args.includes('--list')) { throw new Error('Remove either -e or --list'); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat -e and --list as separate modes: evaluate vs enumerate","Validate flag combinations in wrapper scripts before spawning the CLI"],"tags":["cli","mutually-exclusive-flags","baml"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}