{"record":{"id":"c981b768eff17932","repo":"BoundaryML/baml","slug":"function-name-not-found-use-baml-run-list-to-see-available","errorCode":null,"errorMessage":"function `{name}` not found.\nuse `baml run --list` to see available targets.","messagePattern":"function `(.+?)` not found\\.\nuse `baml run --list` to see available targets\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":1344,"sourceCode":"        let mut candidates: Vec<String> = engine\n            .user_functions()\n            .into_iter()\n            .map(|f| f.display_name)\n            .collect();\n        candidates.sort();\n        candidates.dedup();\n\n        let suggestions: Vec<&str> = candidates\n            .iter()\n            .filter(|c| {\n                c.contains(name) || name.contains(c.as_str()) || strsim::jaro_winkler(c, name) > 0.7\n            })\n            .take(5)\n            .map(String::as_str)\n            .collect();\n\n        if suggestions.is_empty() {\n            anyhow!(\n                \"function `{name}` not found.\\n\\\n                 use `baml run --list` to see available targets.\"\n            )\n        } else {\n            anyhow!(\n                \"function `{name}` not found. Did you mean one of:\\n{}\",\n                suggestions\n                    .iter()\n                    .map(|s| format!(\"  - {s}\"))\n                    .collect::<Vec<_>>()\n                    .join(\"\\n\")\n            )\n        }\n    }\n\n    fn target_not_found_error_in(\n        scripts: &HashMap<String, Vec<String>>,\n        engine: &BexEngine,","sourceCodeStart":1326,"sourceCodeEnd":1362,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L1326-L1362","documentation":"The `baml run --function <name>` flag was given a function name that does not exist among the compiled program's user functions. The CLI builds a sorted candidate list of user function display names, matches against the given name by substring containment or a Jaro-Winkler similarity above 0.7, and throws this variant when no suggestion qualifies. It points the user at `baml run --list` to enumerate available targets.","triggerScenarios":"Running `baml run --function <name>` where `<name>` is not a user function in the compiled BAML project (typo, removed/renamed function, wrong project directory, or a name that only matches scripts/namespaces which are not reachable via `--function`).","commonSituations":"Typos in function names; renaming or deleting a BAML function but running an old script alias or CI command; invoking a script or namespace name via `--function` instead of as a positional target; running in the wrong directory so the target project isn't compiled.","solutions":["Run `baml run --list` to see the exact available function names.","Fix the `--function` argument to the exact display name of an existing BAML function (names are case-sensitive).","If targeting a script or namespace, pass it as a positional target instead of `--function` (e.g. `baml run <script>`).","Verify you are in the correct project root so the intended .baml sources are compiled."],"exampleFix":"// before\nbaml run --function ExtractReusme\n// after\nbaml run --function ExtractResume","handlingStrategy":"validation","validationCode":"// shell: verify the function exists before invoking\nbaml run --list | grep -qx \"$FUNC_NAME\" || { echo \"function $FUNC_NAME not found\"; exit 1; }","typeGuard":null,"tryCatchPattern":"// capture stderr and fall back to --list\nif ! baml run --function \"$FUNC\" 2>err.log; then\n  baml run --list\n  exit 1\nfi","preventionTips":["Copy function names from `baml run --list` instead of typing them.","Keep CI scripts in sync with function renames via grep/lint.","Use positional targets for scripts/namespaces, `--function` only for functions."],"tags":["cli","command-line","function-not-found","baml"],"backgroundTag":"command-not-found","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"}