{"record":{"id":"bb3ce875d120d1a3","repo":"astrid-runtime/astrid","slug":"cargo-reported-compiled-wasm-at-but-the-exact","errorCode":null,"errorMessage":"Cargo reported compiled WASM at {}, but the exact release artifact is {}","messagePattern":"Cargo reported compiled WASM at (.+?), but the exact release artifact is (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-build/src/rust.rs","lineNumber":64,"sourceCode":"\n/// Build a Rust capsule from a crate directory.\n///\n/// 1. `cargo build --release` using Cargo's resolved target/configuration\n/// 2. Extract capsule description via Extism (`astrid_export_schemas`)\n/// 3. Merge description into `Capsule.toml`\n/// 4. Pack into `.capsule` archive\npub(crate) fn build(dir: &Path, output: Option<&str>) -> Result<()> {\n    info!(\"Building Rust WASM capsule from {}\", dir.display());\n\n    verify_cargo_available()?;\n\n    let (meta, crate_name, package_version, wasm_name, package_id) = resolve_package_metadata(dir)?;\n\n    let compiled = compile_wasm(dir, &package_id, &wasm_name)?;\n\n    let wasm_path = locate_wasm_binary(&meta, &compiled.target, &wasm_name)?;\n    if wasm_path != compiled.path {\n        bail!(\n            \"Cargo reported compiled WASM at {}, but the exact release artifact is {}\",\n            compiled.path.display(),\n            wasm_path.display()\n        );\n    }\n    let wasm_path = ensure_component(&wasm_path)?;\n\n    let toml_content =\n        build_manifest_content(dir, &wasm_path, &crate_name, &package_version, &wasm_name)?;\n    let assets = discover_opaque_assets(dir)?;\n    let asset_refs: Vec<&Path> = assets.iter().map(PathBuf::as_path).collect();\n\n    let out_dir = resolve_output_dir(output)?;\n    let out_file = out_dir.join(format!(\"{crate_name}.capsule\"));\n\n    // Stage the wit/ directory — merges the capsule's own wit/ (if any) with\n    // the astrid-sdk shared contracts as a WIT dependency so capsule authors\n    // can reference shared records via `wit_type` without duplication.","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-build/src/rust.rs#L46-L82","documentation":"Fired by build when Cargo metadata resolved a package id but none of its compiled release artifacts exactly matches the resolved cdylib output name. Cargo built something else than expected, so packaging would grab the wrong WASM.","triggerScenarios":"Thrown at crates/astrid-build/src/rust.rs:64 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Declare exactly one cdylib target with the expected output name in Cargo.toml","Clean `target/` and rebuild to remove stale artifacts","Set an explicit `[lib] name` matching the packaged component"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}