BoundaryML/baml · error

no baml.toml found from {} up to the home directory Run this

Error message

no baml.toml found from {} up to the home directory
Run this command inside a BAML project.

What it means

pin_toolchain records the selected toolchain in the nearest baml.toml. It walks from the current directory up to the home directory via find_project_manifest; if no manifest is found, this error tells the user to run the command inside a BAML project, since pinning is meaningless without one.

Source

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

        }
    }
    Ok(selector)
}

fn use_toolchain(selector: &str, override_url: Option<&str>) -> Result<()> {
    let selector = prepare_toolchain_selector(selector, &env::current_dir()?, override_url)?;

    let mut config = read_config();
    config.default.selector.clone_from(&selector);
    write_config(&config)?;
    println!("selected BAML toolchain {selector}");
    Ok(())
}

fn pin_toolchain(selector: &str, override_url: Option<&str>) -> Result<()> {
    let cwd = env::current_dir()?;
    let manifest_path = find_project_manifest(&cwd).ok_or_else(|| {
        anyhow!(
            "no baml.toml found from {} up to the home directory\nRun this command inside a BAML project.",
            cwd.display()
        )
    })?;
    let content = fs::read_to_string(&manifest_path)
        .with_context(|| format!("failed to read {}", manifest_path.display()))?;
    let normalized_selector = normalize_selector(selector, &cwd);
    let selector_key = if is_channel(&normalized_selector) {
        "channel"
    } else if is_path_selector(&normalized_selector) {
        "path"
    } else {
        "version"
    };
    let updated = pin_selector_in_manifest(&content, selector_key, &normalized_selector)
        .with_context(|| format!("failed to update {}", manifest_path.display()))?;

    let selector = prepare_toolchain_selector(&normalized_selector, &cwd, override_url)?;

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. cd into your BAML project directory (one containing baml.toml) and re-run the command.
  2. Create a baml.toml in the project root if the project has none.
  3. Set a global/default toolchain instead if you intentionally have no project here.

Example fix

// before
cd ~ && baml toolchain use canary   // no baml.toml anywhere up the tree
// after
cd ~/my-baml-project   // contains baml.toml
baml toolchain use canary
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs';
import { resolve, dirname, join } from 'path';
function findBamlToml(dir: string): string | null {
  let d = resolve(dir);
  while (true) {
    if (existsSync(join(d, 'baml.toml'))) return join(d, 'baml.toml');
    const parent = dirname(d);
    if (parent === d) return null;
    d = parent;
  }
}

Try / catch

try {
  execFileSync('baml', ['toolchain', 'use', version]);
} catch (e) {
  if (/no baml.toml found/.test(e.stderr?.toString() ?? '')) {
    console.error('Run this command inside a BAML project directory.');
  }
}

Prevention

When it happens

Trigger: Running `baml toolchain use <selector>` (pin_toolchain) from a directory outside any BAML project — find_project_manifest(&cwd) returns None because no baml.toml exists in cwd or any ancestor up to the home directory.

Common situations: Running the command in a scratch/home directory; a project missing its baml.toml (deleted or never committed); being one directory too deep outside the repo.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


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