{"record":{"id":"98c2bb099c54350d","repo":"BoundaryML/baml","slug":"positional-target-is-a-function-name-not-a-file-path-for-a-98c2bb","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 run --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 run --file (.+?) -f <NAME>`\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":485,"sourceCode":"\n        if self.file.is_some() && self.target.is_none() && self.functions.is_empty() {\n            return self.run_single_target(\"main\", reporter);\n        }\n\n        // No target → print help and exit non-zero. (Implicit `main` no\n        // longer exists.)\n        if self.target.is_none() && self.functions.is_empty() {\n            Self::print_run_help();\n            return Ok(crate::ExitCode::Other);\n        }\n\n        if let Some(target) = &self.target {\n            // Helpful redirect when the user typed a path as the\n            // positional (e.g. `baml run baml_src/main.baml`). Positional\n            // `<TARGET>` is always a function name; for a `.baml` source\n            // use `--file`.\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 run --file {target} -f <NAME>`\\n\",\n                );\n            }\n            return self.run_single_target(target, reporter);\n        }\n        self.run_subcommand_targets(reporter)\n    }\n\n    /// Positional `<TARGET>` path: one function, no subcommand layer.\n    /// `[scripts]` aliases are resolved here too (positional only).\n    fn run_single_target(&self, target: &str, reporter: &Reporter) -> Result<crate::ExitCode> {\n        let argv = self.build_argv_for_single(target);\n        let Compiled {\n            db,\n            package,","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L467-L503","documentation":"The positional `<TARGET>` argument of `baml run` is a function (or script) name, never a file path. When the value looks like a path (e.g. `baml_src/main.baml`), the CLI redirects the user to `--file` for single-file source and `-f <NAME>` for the function.","triggerScenarios":"Running e.g. `baml run baml_src/main.baml` — passing a `.baml` file path as the positional target so `looks_like_path(target)` is true.","commonSituations":"Developers accustomed to other CLIs where a file path is the primary argument type a path-style target.","solutions":["Pass the file via `--file` and the function name via `-f <NAME>`","Use `baml run --file <path> -f <functionName>` instead of a positional path","If you meant a function, pass just the function name as the positional"],"exampleFix":"// before\nbaml run baml_src/main.baml\n// after\nbaml run --file baml_src/main.baml -f MyFunction","handlingStrategy":"validation","validationCode":"if (positional && /\\.[^.\\/\\\\]+$|\\//.test(positional)) { throw new Error(`Use --file ${positional} -f <NAME> instead of a positional path`); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember positional <TARGET> is a function/script name, not a path","Use --file for any .baml source path","Keep function names free of path-like characters (/, .ext)"],"tags":["cli","invalid-argument","baml"],"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"}