{"record":{"id":"285958c1414b0379","repo":"BoundaryML/baml","slug":"e-is-not-compatible-with-file-expression-mode-evaluates","errorCode":null,"errorMessage":"`-e` is not compatible with `--file`. Expression mode evaluates inline source; remove one of the two.","messagePattern":"`-e` is not compatible with `--file`\\. Expression mode evaluates inline source; remove one of the two\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":419,"sourceCode":"        if used.len() > 1 {\n            anyhow::bail!(\n                \"{} are mutually exclusive dispatch modes — pick one.\",\n                used.join(\" and \")\n            );\n        }\n\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);","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L401-L437","documentation":"`baml run -e` evaluates inline source, while `--file` changes which source files are loaded. The CLI rejects this combination up front because expression mode short-circuits project/file loading, so `--file` would silently do nothing.","triggerScenarios":"Invoking `baml run` with both an expression passed via `-e <expr>` and a file passed via `--file <path>`.","commonSituations":"A developer combining an example expression snippet with an existing `--file` invocation, or scripting a command that templated both flags.","solutions":["Remove the `--file <path>` argument and keep `-e <expr>`","Remove the `-e <expr>` argument and rely on `--file` plus a function target"],"exampleFix":"// before\nbaml run --file baml_src/main.baml -e 'test()'\n// after\nbaml run -e 'test()'","handlingStrategy":"validation","validationCode":"if (args.includes('-e') && (args.includes('--file') || args.some(a => a.startsWith('--file=')))) { throw new Error('Remove either -e or --file'); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine -e with --file","Build CLI invocations from flag groups (expression vs file) that are known mutually exclusive","Read baml run --help before composing flags"],"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"}