{"record":{"id":"b27a99052da8f77d","repo":"BoundaryML/baml","slug":"cargo-build-failed-for-package","errorCode":null,"errorMessage":"cargo build failed for {package}","messagePattern":"cargo build failed for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/tools_size_gate/src/measure.rs","lineNumber":81,"sourceCode":"        cmd.arg(\"--features\").arg(feat);\n    }\n\n    cmd.args(extra);\n    cmd.current_dir(workspace_root);\n\n    eprintln!(\n        \"  building {} ({})\",\n        package,\n        if config.no_default_features {\n            \"no-default-features\"\n        } else {\n            \"default features\"\n        }\n    );\n\n    let status = cmd.status().context(\"failed to run cargo build\")?;\n    if !status.success() {\n        bail!(\"cargo build failed for {package}\");\n    }\n\n    Ok(())\n}\n\n/// Build the CLI + pack host, then run `baml pack` on the fixture and\n/// return the path to the produced standalone executable.\nfn build_pack(workspace_root: &Path, name: &str, config: &ArtifactConfig) -> Result<PathBuf> {\n    let pack = config.require_pack()?;\n\n    // Build the CLI and the pack host in one release invocation. The host\n    // binary must land next to the CLI in target/release so `baml pack`\n    // resolves it locally (no GitHub download).\n    eprintln!(\"  building {} + {}\", pack.cli_package, pack.host_package);\n    let status = Command::new(\"cargo\")\n        .arg(\"build\")\n        .arg(\"--release\")\n        .args([\"-p\", &pack.cli_package, \"--bin\", &pack.cli_bin])","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_size_gate/src/measure.rs#L63-L99","documentation":"run_cargo_build runs `cargo build` for a package (e.g. the CLI) and checks the exit status; a non-zero status aborts with this message. The underlying compiler errors are printed by cargo itself to stderr before this bail.","triggerScenarios":"Any `cargo build -p <package>` failure during size-gate measure: compile errors, missing feature flags, failing build scripts, or dependency resolution errors for that package.","commonSituations":"Workspace code broken mid-refactor; package name typo in the size-gate config; required feature set unavailable for the target; vendored/offline dependency issues.","solutions":["Read the cargo compiler output printed above this message","Run `cargo build -p <package>` manually in the workspace root to reproduce","Fix the compile errors or restore a working tree (git stash/checkout)","Confirm the package and features configured for the artifact exist"],"exampleFix":"// before: broken package name in artifact config\npackages = [\"baml-cl”]\n// after\ncargo build -p baml-cli  # verify name via workspace Cargo.toml members","handlingStrategy":"try-catch","validationCode":"let status = std::process::Command::new(\"cargo\")\n    .args([\"build\", \"-p\", \"baml-cli\"])\n    .status()?;\nif !status.success() { eprintln!(\"preflight build failed; fix compile errors before measuring\"); std::process::exit(1); }","typeGuard":null,"tryCatchPattern":"match size_gate_result {\n    Err(e) if e.to_string().starts_with(\"cargo build failed\") => {\n        eprintln!(\"workspace does not compile; run `cargo build` and fix errors first\");\n    }\n    other => other?,\n}","preventionTips":["Run `cargo build --workspace` locally before invoking size-gate","Only measure on a clean, compiling tree (CI on green commits)","Keep package names/features in the size-gate config in sync with Cargo.toml","Avoid vendored/offline cargo config surprises in CI"],"tags":["cargo","build","rust","subprocess"],"backgroundTag":"git-command-failed","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"}