{"record":{"id":"a647e10d1a72d251","repo":"BoundaryML/baml","slug":"could-not-find-cargo-toml","errorCode":null,"errorMessage":"Could not find Cargo.toml","messagePattern":"Could not find Cargo\\.toml","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"baml_language/crates/tools_stow/src/main.rs","lineNumber":2584,"sourceCode":"        std::process::exit(1);\n    }\n\n    println!(\"✅ Created {}\", stow_toml.display());\n    println!();\n    println!(\"Next steps:\");\n    println!(\"  1. Edit stow.toml to configure your namespace(s)\");\n    println!(\"  2. Run `cargo stow` to validate your workspace\");\n    println!(\"  3. Run `cargo stow --fix` to auto-fix sortable issues\");\n}\n\nfn main() {\n    let Cargo::Stow(args) = Cargo::parse();\n\n    let ManifestSelection {\n        root_dir: manifest_root,\n        manifest_path: workspace_cargo,\n        is_workspace,\n    } = find_best_manifest().expect(\"Could not find Cargo.toml\");\n\n    let metadata = load_metadata(&workspace_cargo);\n    let workspace_root = PathBuf::from(metadata.workspace_root.as_str());\n\n    // Handle init subcommand first (doesn't require config to exist)\n    if let Some(Command::Init { minimal }) = args.command {\n        run_init(&workspace_root, minimal);\n        return;\n    }\n\n    // Load configuration (required for all other operations)\n    let config = match Config::load(&workspace_root) {\n        Ok(config) => config,\n        Err(ConfigError::NotFound) => {\n            eprintln!(\"Error: No stow.toml found.\");\n            eprintln!();\n            eprintln!(\"Run `cargo stow init` to create a configuration file.\");\n            eprintln!();","sourceCodeStart":2566,"sourceCodeEnd":2602,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_stow/src/main.rs#L2566-L2602","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["cd into your cargo workspace root (directory containing Cargo.toml) before running the stow command.","If no manifest exists, run `cargo init` or `cargo new` first.","Point the tool/CI at the correct project directory.","Verify the repo actually has a Cargo.toml checked out (complete clone, submodules if needed)."],"exampleFix":"// before\\n$ tools_stow stow   # run from ~/random-dir\\n// after\\n$ cd /path/to/baml_language\\n$ tools_stow stow","handlingStrategy":"validation","validationCode":"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}","typeGuard":null,"tryCatchPattern":"// 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});","preventionTips":["Always invoke stow from the workspace root directory.","Add a CI step asserting Cargo.toml exists before tooling runs.","Run `cargo init` for new projects before applying stow.","Verify complete repo checkout (manifest not gitignored/missing)."],"tags":["cli","rust","file-not-found"],"backgroundTag":"config-file-not-found","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"}