BoundaryML/baml · error

toolchain binary is not executable: {}{origin}

Error message

toolchain binary is not executable: {}{origin}

What it means

On Unix, verify_path_toolchain checks that the path toolchain binary has any execute permission bit set (mode & 0o111). If the file exists but is not executable, the wrapper raises this error before attempting to run it. This usually happens when the binary was downloaded or copied without preserving permissions.

Source

Thrown at baml_language/crates/baml/src/main.rs:939

            cli_exe_name(),
            cli.join("bin").join(cli_exe_name()).display()
        ));
    }
    if !cli.exists() {
        return Err(anyhow!(
            "toolchain binary not found: {}{origin}",
            cli.display()
        ));
    }
    #[cfg(unix)]
    {
        use std::os::unix::fs::PermissionsExt;
        let mode = fs::metadata(cli)
            .with_context(|| format!("failed to read {}", cli.display()))?
            .permissions()
            .mode();
        if mode & 0o111 == 0 {
            return Err(anyhow!(
                "toolchain binary is not executable: {}{origin}",
                cli.display()
            ));
        }
    }
    Ok(())
}

/// Bold-yellow lowercase `warning` prefix, matching the styled diagnostics the
/// toolchain CLI emits (see `baml_exec::diag_print`). Color is dropped
/// automatically when stderr is not a TTY.
fn warning_prefix() -> impl std::fmt::Display {
    console::Style::new()
        .yellow()
        .bold()
        .for_stderr()
        .apply_to("warning")
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Add the execute bit: chmod +x <path-to-baml-binary>.
  2. Re-extract the toolchain archive with a Unix-native tool (tar) so permissions are preserved.
  3. Reinstall the toolchain via `baml toolchain install <version>`.

Example fix

// before
ls -l toolchain/bin/baml  # -rw-r--r-- (not executable)
// after
chmod +x toolchain/bin/baml
Defensive patterns

Strategy: validation

Validate before calling

const p = '/opt/baml/0.210.0/bin/baml';
if ((fs.statSync(p).mode & 0o111) === 0) fs.chmodSync(p, 0o755);

Type guard

function isExecutable(p: string): boolean {
  try { return (fs.statSync(p).mode & 0o111) !== 0; } catch { return false; }
}

Prevention

When it happens

Trigger: Calling a path-resolving command (print_version, exec_path_toolchain, prepare_toolchain_selector, status_toolchain) with a path selector whose file mode & 0o111 == 0; metadata read failure is separately wrapped as "failed to read <path>".

Common situations: Copying a baml binary from an archive extracted with non-Unix tools that drop the exec bit; checking the binary into git and checking it out without +x; sharing binaries over network shares.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/0a9e78ac1f2e1c6d. Report an issue: GitHub.