{"record":{"id":"d6370243277a0089","repo":"BoundaryML/baml","slug":"failed-to-determine-active-baml-toolchain-root","errorCode":null,"errorMessage":"failed to determine active BAML toolchain root","messagePattern":"failed to determine active BAML toolchain root","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/ide_command.rs","lineNumber":208,"sourceCode":"\n  1. Save baml-vscode.vsix somewhere easy to find:\n\n         baml ide install --output-dir {dir}\n\n  2. In {ide}, press {chord} and run \"Extensions: Install from VSIX...\".\n\n  3. Select the saved baml-vscode.vsix.\"#,\n        dir = os.example_dir(),\n        chord = os.palette_chord(),\n    )\n}\n\nfn active_toolchain_vsix() -> Result<PathBuf> {\n    let exe = env::current_exe().context(\"failed to locate baml-cli executable\")?;\n    let toolchain_root = exe\n        .parent()\n        .and_then(Path::parent)\n        .ok_or_else(|| anyhow!(\"failed to determine active BAML toolchain root\"))?;\n    let vsix = toolchain_root.join(\"assets\").join(\"baml-vscode.vsix\");\n    if !vsix.exists() {\n        // A local build has no assets/ next to it, so say that plainly rather\n        // than reporting a missing file the developer never expected to exist.\n        if let Some(local) = env::var_os(\"BAML_WRAPPER_LOCAL_TOOLCHAIN\") {\n            anyhow::bail!(\n                \"baml ide install needs a managed BAML toolchain, but the active one is a local binary at {}.\\nThe VS Code extension ships with released toolchains only.\\nRun: baml toolchain use canary\",\n                Path::new(&local).display()\n            );\n        }\n        anyhow::bail!(\n            \"active BAML toolchain does not include assets/baml-vscode.vsix at {}\",\n            vsix.display()\n        );\n    }\n    Ok(vsix)\n}\n","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/ide_command.rs#L190-L226","documentation":"`active_toolchain_vsix` locates the VSIX by taking the running executable's parent's parent as the toolchain root. If the baml executable sits less than two directories deep in the filesystem, that root cannot be determined and this error is raised.","triggerScenarios":"Running `baml ide install` when env::current_exe() returns a path whose grandparent does not exist — e.g. the binary placed directly in a root-level or single-level directory like /bin/baml or a bare temp dir.","commonSituations":"Running a baml binary copied to an unusual location (filesystem root, /usr/bin-style single-level path) instead of the standard managed toolchain layout <root>/bin/baml.","solutions":["Run baml via the managed toolchain layout (<toolchain-root>/bin/baml)","Use `baml toolchain use canary` (or similar) to activate a properly installed toolchain","Avoid running the binary from a top-level directory with no grandparent"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# ensure baml is invoked from the managed layout <root>/bin/baml\nexe=\"$(command -v baml)\"\ntest \"$(dirname \"$(dirname \"$exe\")\")\" != \"/\" || echo \"non-standard install location\"","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"toolchain root\") => {\n        eprintln!(\"Run baml through the managed toolchain (baml toolchain use canary).\");\n    }\n    other => other?,\n}","preventionTips":["Install baml via the official toolchain manager, not by copying the binary","Avoid placing the binary in single-level directories like /bin or /","Symlink rather than move the managed binary when adding to PATH"],"tags":["toolchain","path","install"],"backgroundTag":"unexpected-install-layout","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"}