{"record":{"id":"569ee6baffdfc627","repo":"BoundaryML/baml","slug":"toolchain-path-is-a-directory-origin-point-at-the-binary-e-g","errorCode":null,"errorMessage":"toolchain path is a directory: {}{origin}\nPoint at the {} binary, e.g. {}","messagePattern":"toolchain path is a directory: (.+?)(.+?)\nPoint at the (.+?) binary, e\\.g\\. (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml/src/main.rs","lineNumber":918,"sourceCode":"        (Ok(current), Ok(cli)) => current == cli,\n        _ => current == cli,\n    };\n    if same {\n        return Err(anyhow!(\n            \"toolchain path points at the baml wrapper itself: {}{origin}\\nPoint at the {} binary instead, which is built alongside it.\",\n            cli.display(),\n            cli_exe_name()\n        ));\n    }\n    Ok(())\n}\n\n/// Check that a path selector points at something runnable. `origin` is a\n/// pre-formatted `set by ...` line, or empty when the path came straight from\n/// the command line and needs no attribution.\nfn verify_path_toolchain(cli: &Path, origin: &str) -> Result<()> {\n    if cli.is_dir() {\n        return Err(anyhow!(\n            \"toolchain path is a directory: {}{origin}\\nPoint at the {} binary, e.g. {}\",\n            cli.display(),\n            cli_exe_name(),\n            cli.join(\"bin\").join(cli_exe_name()).display()\n        ));\n    }\n    if !cli.exists() {\n        return Err(anyhow!(\n            \"toolchain binary not found: {}{origin}\",\n            cli.display()\n        ));\n    }\n    #[cfg(unix)]\n    {\n        use std::os::unix::fs::PermissionsExt;\n        let mode = fs::metadata(cli)\n            .with_context(|| format!(\"failed to read {}\", cli.display()))?\n            .permissions()","sourceCodeStart":900,"sourceCodeEnd":936,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml/src/main.rs#L900-L936","documentation":"verify_path_toolchain validates that a `--path` toolchain selector points at a runnable binary, not a directory. When the given path is a directory (commonly the toolchain root itself), the wrapper rejects it and hints at the correct binary location (root/bin/baml). This guards against users pointing at the extracted distribution folder instead of the executable inside it.","triggerScenarios":"Calling any command that resolves a path-based toolchain (print_version, exec_path_toolchain, prepare_toolchain_selector, status_toolchain) with a path selector where `cli.is_dir()` is true — i.e. the user passed a directory such as the toolchain root.","commonSituations":"Setting BAML_TOOLCHAIN_PATH (or --path flag) to the extracted toolchain directory or a home/toolchains/<version> folder instead of the bin/baml binary; autocompletion selecting a directory; scripts that resolve a version directory and forget to append bin/baml.","solutions":["Point the path selector at the binary itself, e.g. <toolchain-root>/bin/baml, not the root directory.","If the path was set via an env var, update it: export BAML_TOOLCHAIN_PATH=/path/to/toolchain/bin/baml.","Run `baml toolchain status` to see the current selector and its origin, then correct it with `baml toolchain use <version>` if a managed toolchain was intended."],"exampleFix":"// before\nbaml --path ~/toolchains/0.210.0 --version\n// after\nbaml --path ~/toolchains/0.210.0/bin/baml --version","handlingStrategy":"validation","validationCode":"const p = process.env.BAML_TOOLCHAIN_PATH!;\nconst st = fs.statSync(p);\nif (st.isDirectory()) throw new Error(`Point BAML_TOOLCHAIN_PATH at the binary, e.g. ${p}/bin/baml`);","typeGuard":"function isExecutableFilePath(p: string): boolean {\n  try { return fs.statSync(p).isFile(); } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Always append /bin/baml when pointing at a toolchain root directory.","Validate toolchain paths in scripts with a stat check before invoking baml.","Prefer managed toolchains (`baml toolchain use <version>`) over raw --path overrides."],"tags":["cli","toolchain","path"],"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"}