{"record":{"id":"4b271435464088a8","repo":"BoundaryML/baml","slug":"cargo-build-failed-for-pack","errorCode":null,"errorMessage":"cargo build failed for pack ({} + {})","messagePattern":"cargo build failed for pack \\((.+?) \\+ (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/tools_size_gate/src/measure.rs","lineNumber":105,"sourceCode":"/// 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])\n        .args([\"-p\", &pack.host_package, \"--bin\", &pack.host_bin])\n        .current_dir(workspace_root)\n        .status()\n        .context(\"failed to run cargo build for pack\")?;\n    if !status.success() {\n        bail!(\n            \"cargo build failed for pack ({} + {})\",\n            pack.cli_package,\n            pack.host_package\n        );\n    }\n\n    run_baml_pack(workspace_root, name, pack)\n}\n\n/// Run the freshly built CLI's `baml pack` on the fixture, writing the\n/// output to a deterministic path under `target/size-gate/`.\nfn run_baml_pack(workspace_root: &Path, name: &str, pack: &PackConfig) -> Result<PathBuf> {\n    let cli_path = workspace_root\n        .join(\"target/release\")\n        .join(exe_filename(&pack.cli_bin));\n    if !cli_path.exists() {\n        bail!(\"pack CLI not found at {}\", cli_path.display());\n    }","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_size_gate/src/measure.rs#L87-L123","documentation":"build_pack builds both the pack's CLI binary and host binary with a single `cargo build -p <cli_package> --bin <cli_bin> -p <host_package> --bin <host_bin>` invocation. If cargo exits non-zero, it bails naming both packages. Cargo's own diagnostics are already on stderr.","triggerScenarios":"Failure building either the CLI or host package/bin pair defined in the PackConfig during size-gate measure: compile errors in either crate, missing bins, or broken build scripts.","commonSituations":"Renamed bin or package targets in Cargo.toml without updating the pack config; compile errors introduced on the branch under test; host crate requiring a feature only available on certain platforms.","solutions":["Read cargo's error output above the message to see which of the two targets failed","Build each target manually: cargo build -p <cli_package> --bin <cli_bin>, then the host","Verify package/bin names in the pack config match Cargo.toml","Fix the compile errors or test on a clean checkout"],"exampleFix":"// before: bin renamed in Cargo.toml but not in config\ncli_bin = \"baml-old\"\n// after\ncli_bin = \"baml\"","handlingStrategy":"try-catch","validationCode":"let status = std::process::Command::new(\"cargo\")\n    .args([\"build\", \"-p\", cli_pkg, \"--bin\", cli_bin, \"-p\", host_pkg, \"--bin\", host_bin])\n    .status()?;\nif !status.success() { eprintln!(\"pack targets do not build; check bin/package names\"); std::process::exit(1); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = measure() {\n    if e.to_string().contains(\"cargo build failed for pack\") {\n        eprintln!(\"build the two pack targets manually to see which failed\");\n    }\n    return Err(e);\n}","preventionTips":["Verify cli/host package and bin names against Cargo.toml when renaming targets","Build both pack targets in a preflight CI job before measuring","Gate size measurements on the unit-test CI job passing","Test pack builds on all target platforms the gate runs on"],"tags":["cargo","build","pack","rust"],"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"}