{"record":{"id":"ddca06c21f87331b","repo":"BoundaryML/baml","slug":"no-target-specified-pass-a-positional-target-to-pack-one","errorCode":null,"errorMessage":"no target specified. Pass a positional `<TARGET>` to pack one function as the binary's only entry point, or one or more `-f <NAME>` flags to pack a subcommand binary.","messagePattern":"no target specified\\. Pass a positional `<TARGET>` to pack one function as the binary's only entry point, or one or more `-f <NAME>` flags to pack a subcommand binary\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/pack_command.rs","lineNumber":252,"sourceCode":"        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() {\n            Some(target) => validate_release_target_triple(target),\n            None => release_host_target_triple(),\n        }\n    }\n\n    fn load_and_compile(&self, reporter: &Reporter) -> Result<(ProjectDatabase, Program, bool)> {\n        if let Some(file) = self.file.as_deref() {\n            // Standalone `--file` mode has no project root, so there is no","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/pack_command.rs#L234-L270","documentation":"validate_flags rejects a `baml pack` invocation that names no pack target at all: neither a positional `<TARGET>` nor any `-f <NAME>` flag was given. Since `baml pack` cannot infer which function(s) to package, it bails with guidance on the two supported targeting styles.","triggerScenarios":"Running bare `baml pack` (or `baml pack --file <PATH>` with no `-f` and no positional) with no target and no functions specified.","commonSituations":"Users type `baml pack` expecting it to pack the whole project by default; a script drops the positional because a variable is empty; someone ports a `baml run` invocation that used different targeting flags.","solutions":["Pass a positional `<TARGET>` to pack one function as the binary's only entry point, e.g. `baml pack MyFunction`.","Pass one or more `-f <NAME>` flags to pack a subcommand binary, e.g. `baml pack -f Foo -f Bar`.","Use `baml run --list` to see available function names if unsure what to target."],"exampleFix":"// before\nbaml pack\n\n// after\nbaml pack MyFunction\n// or\nbaml pack -f MyFunction","handlingStrategy":"validation","validationCode":"// ensure at least one target before invoking\nif [ -z \"$TARGET\" ] && [ -z \"$FUNCTIONS\" ]; then\n  echo \"usage: baml pack <TARGET> | baml pack -f NAME [-f NAME...]\" >&2; exit 2\nfi\nbaml pack $TARGET $FUNCTIONS","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never invoke bare `baml pack`; always include a positional target or at least one `-f` flag.","In scripts, fail early if target variables are empty (use ${VAR:?} expansion).","Use `baml run --list` to pick valid targets when composing commands."],"tags":["cli","missing-argument","baml-pack"],"backgroundTag":"missing-required-argument","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"}