{"record":{"id":"8cbd721c9988a998","repo":"astrid-runtime/astrid","slug":"cargo-emitted-release-cdylib-artifacts-named-e","errorCode":null,"errorMessage":"Cargo emitted {} release cdylib artifacts named {expected_filename}; refusing to choose an ambiguous artifact","messagePattern":"Cargo emitted (.+?) release cdylib artifacts named (.+?); refusing to choose an ambiguous artifact","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-build/src/rust.rs","lineNumber":310,"sourceCode":"    let status = child.wait().context(\"Failed to wait for cargo build\")?;\n\n    if !status.success() {\n        bail!(\n            \"Cargo build failed. Set `[build] target = \\\"wasm32-unknown-unknown\\\"` (Astrid-canonical) or `wasm32-wasip2` in `.cargo/config.toml` and install the matching `rustup target` component.\"\n        );\n    }\n\n    artifacts.sort();\n    artifacts.dedup();\n    match artifacts.as_slice() {\n        [path] => Ok(CompiledWasm {\n            target,\n            path: path.clone(),\n        }),\n        [] => bail!(\n            \"Cargo completed without emitting the exact release cdylib artifact {expected_filename}\"\n        ),\n        _ => bail!(\n            \"Cargo emitted {} release cdylib artifacts named {expected_filename}; refusing to choose an ambiguous artifact\",\n            artifacts.len()\n        ),\n    }\n}\n\nfn inject_getrandom_for_target(target: &str) -> bool {\n    target == GETRANDOM_TARGET\n}\n\n/// Append the custom getrandom cfg without replacing any effective Cargo\n/// rustflags. Cargo's precedence is encoded-rustflags env, plain rustflags env,\n/// target-specific rustflags env, matching target config, then build\n/// rustflags. We modify only the first effective environment source. When\n/// config-derived flags are effective (including when `CARGO_BUILD_RUSTFLAGS`\n/// is shadowed by matching target entries), a Cargo config override preserves\n/// Cargo's own hierarchy and reaches every dependency.\nfn append_getrandom_rustflag(","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-build/src/rust.rs#L292-L328","documentation":"Fired by compile_wasm_with_target when cargo emits multiple distinct release artifacts with the same expected cdylib filename (e.g. from multiple builds/compilers), so the correct WASM cannot be chosen unambiguously.","triggerScenarios":"Thrown at crates/astrid-build/src/rust.rs:310 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clean the target directory (`cargo clean`) and rebuild","Avoid building the same cdylib with multiple configurations into one target dir","Use distinct target directories per configuration"],"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"}