{"record":{"id":"36330c26a0eb8e2a","repo":"astrid-runtime/astrid","slug":"capsule-has-no-cdylib-target-refusing-to-guess-a","errorCode":null,"errorMessage":"Capsule has no cdylib target; refusing to guess a WASM artifact","messagePattern":"Capsule has no cdylib target; refusing to guess a WASM artifact","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-build/src/rust.rs","lineNumber":168,"sourceCode":"/// cdylib target cannot produce the artifact this builder packages, so it is\n/// rejected rather than guessing a same-named binary.\nfn resolve_wasm_output_name(package: &cargo_metadata::Package) -> Result<String> {\n    resolve_wasm_output_name_from_targets(\n        package\n            .targets\n            .iter()\n            .filter(|target| target.is_cdylib())\n            .map(|target| target.name.clone()),\n    )\n}\n\nfn resolve_wasm_output_name_from_targets<I>(output_names: I) -> Result<String>\nwhere\n    I: IntoIterator<Item = String>,\n{\n    let output_names: Vec<String> = output_names.into_iter().collect();\n    match output_names.as_slice() {\n        [] => bail!(\"Capsule has no cdylib target; refusing to guess a WASM artifact\"),\n        [output_name] => validate_wasm_output_name(output_name),\n        _ => bail!(\n            \"Capsule has {} cdylib targets; refusing to choose an ambiguous WASM artifact\",\n            output_names.len()\n        ),\n    }\n}\n\nfn validate_wasm_output_name(output_name: &str) -> Result<String> {\n    let path = Path::new(output_name);\n    let is_single_normal_component =\n        output_name != \".\" && output_name != \"..\" && path.file_name() == Some(path.as_os_str());\n    if !is_single_normal_component {\n        bail!(\"Unsafe WASM artifact name: {output_name}\");\n    }\n    Ok(output_name.to_owned())\n}\n","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-build/src/rust.rs#L150-L186","documentation":"Sentinel arm of resolve_wasm_output_name_from_targets: after filtering the package's cargo targets for cdylib kind, the list is empty, so there is no WASM artifact to package. The builder refuses to fall back to guessing a same-named binary target because a bin target produces a native executable, not the required .wasm. Fires for crates declared without crate-type = [\"cdylib\"].","triggerScenarios":"Thrown at crates/astrid-build/src/rust.rs:168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add `[lib] crate-type = [\"cdylib\"]` to Cargo.toml","Check for a typo in the crate-type list","Restructure so the WASM-producing crate is the one being built"],"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"}