{"record":{"id":"cb29c9c017797f8b","repo":"BoundaryML/baml","slug":"expression-mode-e-expression-is-not-packageable-pass-a","errorCode":null,"errorMessage":"expression mode (`-e` / `--expression`) is not packageable; pass a positional `<TARGET>` or `-f <NAME>` instead.","messagePattern":"expression mode \\(`-e` / `--expression`\\) is not packageable; pass a positional `<TARGET>` or `-f <NAME>` instead\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/pack_command.rs","lineNumber":225,"sourceCode":"                })?;\n        }\n\n        // Cargo's `Finished` is `<artifact-or-profile> [metadata]\n        // in <elapsed>`. Mirror that: the artifact location is the\n        // primary fact, with target name + triple in brackets so\n        // the user can see what was packed and for which platform\n        // without parsing an ambiguous arrow.\n        reporter.finish(\n            \"Finished\",\n            format!(\"{} [{label}, {}]\", output_path.display(), target_triple),\n        );\n        Ok(crate::ExitCode::Success)\n    }\n\n    /// Validate flag combinations the clap-side `Args` derive can't catch.\n    fn validate_flags(&self) -> Result<()> {\n        if self.expression.is_some() {\n            anyhow::bail!(\n                \"expression mode (`-e` / `--expression`) is not packageable; \\\n                 pass a positional `<TARGET>` or `-f <NAME>` instead.\"\n            );\n        }\n        // `--file` and `--project` both name a source location. Reject the\n        // combination up front instead of silently preferring one. Same rule\n        // as `baml run`.\n        validate_file_project_flags(self.file.as_deref(), self.from.as_deref())?;\n        if let Some(target) = self.target.as_deref() {\n            if looks_like_path(target) {\n                anyhow::bail!(\n                    \"positional `<TARGET>` is a function name, not a file path. \\\n                     For a single-file source, use `--file {target}` and pass the \\\n                     function via `-f <NAME>`. For example:\\n\\\n                     \\n    `baml pack --file {target} -f <NAME>`\\n\",\n                );\n            }\n            if !self.functions.is_empty() {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/pack_command.rs#L207-L243","documentation":"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.","triggerScenarios":"Run `baml pack -e '<expression>'` (or `--expression ...`) with or without a positional target.","commonSituations":"Copy-pasting a `baml run -e ...` invocation and changing the verb to `pack` without adjusting flags.","solutions":["Drop `-e`/`--expression` and pass a positional function name: `baml pack <TARGET>`.","Use `-f <NAME>` to select the function when sourcing a single file with `--file`.","Use `baml run -e ...` for expression evaluation instead of pack."],"exampleFix":"// before\nbaml pack -e \"myFn(x)\"\n// after\nbaml pack myFn","handlingStrategy":"validation","validationCode":"# guard before `baml pack ...`\ncase \" $@ \" in *\" -e \"*|*\" --expression\"*) echo \"-e is not packageable\"; exit 1;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reuse `baml run -e` invocations for pack","Keep pack targets to positional names or -f/--file","Separate run vs pack command templates in scripts"],"tags":["cli","flags","pack","expression-mode"],"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-14T05:17:10.506Z"}