{"record":{"id":"20d86e0406cd5b4f","repo":"BoundaryML/baml","slug":"positional-target-and-f-function-are-mutually-exclusive-use","errorCode":null,"errorMessage":"positional `<TARGET>` and `-f/--function` are mutually exclusive — use one or the other (positional packs a single-entry binary; `-f` produces a subcommand binary).","messagePattern":"positional `<TARGET>` and `-f/--function` are mutually exclusive — use one or the other \\(positional packs a single-entry binary; `-f` produces a subcommand binary\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/pack_command.rs","lineNumber":244,"sourceCode":"                \"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() {\n                anyhow::bail!(\n                    \"positional `<TARGET>` and `-f/--function` are mutually exclusive — \\\n                     use one or the other (positional packs a single-entry binary; \\\n                     `-f` produces a subcommand binary).\"\n                );\n            }\n        }\n        if self.target.is_none() && self.functions.is_empty() {\n            anyhow::bail!(\n                \"no target specified. Pass a positional `<TARGET>` to pack one \\\n                 function as the binary's only entry point, or one or more \\\n                 `-f <NAME>` flags to pack a subcommand binary.\"\n            );\n        }\n        Ok(())\n    }\n\n    fn resolved_target_triple(&self) -> Result<&str> {\n        match self.target_triple.as_deref() {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/pack_command.rs#L226-L262","documentation":"This error comes from `baml pack` argument validation in validate_flags. The positional `<TARGET>` argument and the `-f/--function` flag are two mutually exclusive ways to select what to pack: the positional packs a single-entry binary, while `-f` produces a subcommand binary. Supplying both is ambiguous, so the CLI refuses to run.","triggerScenarios":"Running `baml pack` with both a positional target (or `--file <PATH>`) and one or more `-f/--function` flags, e.g. `baml pack my_target -f MyFunc`.","commonSituations":"Developers switching from single-entry packing to subcommand packing (or vice versa) leave the old argument in place; shell scripts grow an extra flag; users copy a documented `-f` example but keep a positional from autocomplete or muscle memory.","solutions":["Remove the `-f/--function` flags if you want a single-entry binary from the positional `<TARGET>` (or `--file <PATH>`).","Remove the positional `<TARGET>` (or `--file`) and keep `-f <NAME>` flags if you want a subcommand binary.","Run `baml pack --help` to review which argument style you intend and keep exactly one."],"exampleFix":"// before\nbaml pack MyFunction -f OtherFunction\n\n// after (single-entry binary)\nbaml pack MyFunction\n// or (subcommand binary)\nbaml pack -f MyFunction -f OtherFunction","handlingStrategy":"validation","validationCode":"// shell guard before invoking the CLI\nif [ -n \"$TARGET\" ] && [ -n \"$FUNCTIONS\" ]; then\n  echo \"pass either positional TARGET or -f flags, not both\" >&2; exit 2\nfi\nbaml pack $TARGET $FUNCTIONS","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide upfront whether you want a single-entry binary (positional) or a subcommand binary (-f) and use only that style per invocation.","Wrap `baml pack` invocations in scripts with explicitly separated argument groups.","Review `baml pack --help` before composing new invocations."],"tags":["cli","argument-validation","baml-pack"],"backgroundTag":"mutually-exclusive-options","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"}