{"record":{"id":"6ed1d8441c6c45cb","repo":"BoundaryML/baml","slug":"positional-target-is-a-function-name-not-a-file-path-for-a","errorCode":null,"errorMessage":"positional `<TARGET>` is a function name, not a file path. For a single-file source, use `--file {target}` and pass the function via `-f <NAME>`. For example:\n\n    `baml pack --file {target} -f <NAME>`\n","messagePattern":"positional `<TARGET>` is a function name, not a file path\\. For a single-file source, use `--file (.+?)` and pass the function via `-f <NAME>`\\. For example:\n\n    `baml pack --file (.+?) -f <NAME>`\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/pack_command.rs","lineNumber":236,"sourceCode":"        );\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() {\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 \\","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/pack_command.rs#L218-L254","documentation":"validate_flags checks the positional `<TARGET>` with looks_like_path; if it resembles a file path, the command bails explaining that the positional is a function name, and that single-file sources must use `--file <path>` plus `-f <function-name>`.","triggerScenarios":"Run `baml pack some/path/to_file.baml` (or any path-looking positional) instead of a bare function name.","commonSituations":"Users familiar with `baml run <file.baml>` assuming pack takes a path, or tab-completing a .baml file into the positional slot.","solutions":["Pass just the function name: `baml pack myFunction`.","For a single-file source, use `baml pack --file path/to_file.baml -f myFunction`.","Keep project-rooted invocation (no path positional) and select targets via `-f`."],"exampleFix":"// before\nbaml pack ./baml_src/prompt.baml\n// after\nbaml pack --file ./baml_src/prompt.baml -f myFunction","handlingStrategy":"validation","validationCode":"# guard: positional must not look like a path\nTARGET=\"$1\"\ncase \"$TARGET\" in */*|*.baml) echo \"use --file $TARGET -f <NAME>\"; exit 1;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass bare function names positionally to pack","Use --file for single-file sources with -f for the function","Avoid tab-completing .baml paths into the target slot"],"tags":["cli","flags","pack","path-vs-name"],"backgroundTag":"invalid-cli-argument","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}