{"record":{"id":"ecb2c1b2ffd4aec5","repo":"rust-lang/cargo","slug":"dependency-in-package-requires-a-ar","errorCode":null,"errorMessage":"dependency `{}` in package `{}` requires a `{}` artifact to be present.","messagePattern":"dependency `(.+?)` in package `(.+?)` requires a `(.+?)` artifact to be present\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/compiler/artifact.rs","lineNumber":124,"sourceCode":"    let mut out = HashSet::default();\n    let artifact_requirements = artifact_dep.artifact().expect(\"artifact present\");\n    for artifact_kind in artifact_requirements.kinds() {\n        let mut extend = |kind, filter: &dyn Fn(&&Target) -> bool| {\n            let mut iter = targets.iter().filter(filter).peekable();\n            let found = iter.peek().is_some();\n            out.extend(std::iter::repeat(kind).zip(iter));\n            found\n        };\n        let found = match artifact_kind {\n            ArtifactKind::Cdylib => extend(artifact_kind, &|t| t.is_cdylib()),\n            ArtifactKind::Staticlib => extend(artifact_kind, &|t| t.is_staticlib()),\n            ArtifactKind::AllBinaries => extend(artifact_kind, &|t| t.is_bin()),\n            ArtifactKind::SelectedBinary(bin_name) => extend(artifact_kind, &|t| {\n                t.is_bin() && t.name() == bin_name.as_str()\n            }),\n        };\n        if !found {\n            anyhow::bail!(\n                \"dependency `{}` in package `{}` requires a `{}` artifact to be present.\",\n                artifact_dep.name_in_toml(),\n                parent_package,\n                artifact_kind\n            );\n        }\n    }\n    Ok(out)\n}\n","sourceCodeStart":106,"sourceCodeEnd":134,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/compiler/artifact.rs#L106-L134","documentation":"During dependency artifact resolution, Cargo matches a dependency's required artifact kind (cdylib/staticlib/bin) against the targets produced by the dependency. If none of the dependency's targets satisfy the required artifact kind, it bails naming the dependency, the parent package, and the missing artifact kind.","triggerScenarios":"A package declares a dependency with `artifact = ...` requiring a cdylib/staticlib/specific bin, but the dependency crate does not produce that artifact kind (e.g. requires a cdylib but the dep only builds an rlib; requires a named bin that doesn't exist). Encountered with cargo's bin/cdylib artifact dependencies feature.","commonSituations":"Misconfigured `artifact = \"cdylib\"` on a dependency that is a pure Rust library (rlib only); requiring a `bin` artifact with a `lib`-only crate; typo in the bin name for SelectedBinary; cross-compilation where the target lacks the artifact.","solutions":["Ensure the dependency crate actually produces the required artifact (add `crate-type = [\"cdylib\"]` / `[[bin]]` to the dependency's Cargo.toml).","Change the dependency declaration's artifact kind to match what the dependency produces.","For SelectedBinary, verify the bin name matches a `[[bin]] name = ...` in the dependency."],"exampleFix":"// before\n# parent Cargo.toml\n[dependencies]\nfoo = { version = \"1\", artifact = \"cdylib\" }\n# foo only has crate-type = [\"rlib\"]\n// after\n# foo's Cargo.toml\n[lib]\ncrate-type = [\"rlib\", \"cdylib\"]","handlingStrategy":"validation","validationCode":"// Cross-check artifact kind against the dependency's declared targets\nlet dep_manifest = fetch_dep_manifest(&dep)?;\nlet produces = dep_manifest.lib_crate_types();\nif !produces.contains(&required_artifact) {\n    eprintln!(\"dep {dep} does not produce {required_artifact}\");\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Match artifact = ... to a crate-type/target the dependency actually declares.","Verify [[bin]] names exactly when using bin artifacts."],"tags":["cargo","dependencies","artifact","build","configuration"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}