BoundaryML/baml · critical

Could not find Cargo.toml

Error message

Could not find Cargo.toml

What it means

In main, find_best_manifest() locates the most appropriate Cargo.toml (workspace root or nearest manifest). Its result is unwrapped with expect("Could not find Cargo.toml"), so when no manifest can be found from the current directory the tool panics with this message. It is a precondition check: stow cannot operate without a manifest.

Source

Thrown at baml_language/crates/tools_stow/src/main.rs:2584

        std::process::exit(1);
    }

    println!("✅ Created {}", stow_toml.display());
    println!();
    println!("Next steps:");
    println!("  1. Edit stow.toml to configure your namespace(s)");
    println!("  2. Run `cargo stow` to validate your workspace");
    println!("  3. Run `cargo stow --fix` to auto-fix sortable issues");
}

fn main() {
    let Cargo::Stow(args) = Cargo::parse();

    let ManifestSelection {
        root_dir: manifest_root,
        manifest_path: workspace_cargo,
        is_workspace,
    } = find_best_manifest().expect("Could not find Cargo.toml");

    let metadata = load_metadata(&workspace_cargo);
    let workspace_root = PathBuf::from(metadata.workspace_root.as_str());

    // Handle init subcommand first (doesn't require config to exist)
    if let Some(Command::Init { minimal }) = args.command {
        run_init(&workspace_root, minimal);
        return;
    }

    // Load configuration (required for all other operations)
    let config = match Config::load(&workspace_root) {
        Ok(config) => config,
        Err(ConfigError::NotFound) => {
            eprintln!("Error: No stow.toml found.");
            eprintln!();
            eprintln!("Run `cargo stow init` to create a configuration file.");
            eprintln!();

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. cd into your cargo workspace root (directory containing Cargo.toml) before running the stow command.
  2. If no manifest exists, run `cargo init` or `cargo new` first.
  3. Point the tool/CI at the correct project directory.
  4. Verify the repo actually has a Cargo.toml checked out (complete clone, submodules if needed).

Example fix

// before\n$ tools_stow stow   # run from ~/random-dir\n// after\n$ cd /path/to/baml_language\n$ tools_stow stow
Defensive patterns

Strategy: validation

Validate before calling

if !std::path::Path::new("Cargo.toml").exists() {\n    eprintln!("No Cargo.toml found here; run from your cargo workspace root");\n    std::process::exit(1);\n}

Try / catch

// the tool uses expect(), so guard before invoking:\nstd::panic::catch_unwind(|| tools_stow::main_entry()).unwrap_or_else(|_| {\n    eprintln!("Could not find Cargo.toml — cd to workspace root and retry");\n});

Prevention

When it happens

Trigger: Running the stow CLI (Cargo::parse to Stow subcommand) from a directory where find_best_manifest cannot locate any Cargo.toml walking up the tree.

Common situations: Running the binary outside any cargo project; repository without a workspace manifest at the expected root; wrong working directory in CI; manifest named/located non-standardly.

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/a647e10d1a72d251. Report an issue: GitHub.