{"record":{"id":"d828e9b48c94aa58","repo":"rust-lang/cargo","slug":"is-not-a-valid-artifact-specifier","errorCode":null,"errorMessage":"'{}' is not a valid artifact specifier","messagePattern":"'(.+?)' is not a valid artifact specifier","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/workspace/dependency.rs","lineNumber":648,"sourceCode":"\n    pub fn as_str(&self) -> Cow<'static, str> {\n        match *self {\n            ArtifactKind::SelectedBinary(name) => format!(\"bin:{}\", name.as_str()).into(),\n            _ => self.crate_type().into(),\n        }\n    }\n\n    pub fn parse(kind: &str) -> CargoResult<Self> {\n        Ok(match kind {\n            \"bin\" => ArtifactKind::AllBinaries,\n            \"cdylib\" => ArtifactKind::Cdylib,\n            \"staticlib\" => ArtifactKind::Staticlib,\n            _ => {\n                return kind\n                    .strip_prefix(\"bin:\")\n                    .map(|bin_name| ArtifactKind::SelectedBinary(bin_name.into()))\n                    .ok_or_else(|| {\n                        anyhow::anyhow!(\"'{}' is not a valid artifact specifier\", kind)\n                    });\n            }\n        })\n    }\n\n    fn validate(kinds: Vec<ArtifactKind>) -> CargoResult<Vec<ArtifactKind>> {\n        if kinds.iter().any(|k| matches!(k, ArtifactKind::AllBinaries))\n            && kinds\n                .iter()\n                .any(|k| matches!(k, ArtifactKind::SelectedBinary(_)))\n        {\n            anyhow::bail!(\n                \"Cannot specify both 'bin' and 'bin:<name>' binary artifacts, as 'bin' selects all available binaries.\"\n            );\n        }\n        let mut kinds_without_dupes = kinds.clone();\n        kinds_without_dupes.sort();\n        kinds_without_dupes.dedup();","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/workspace/dependency.rs#L630-L666","documentation":"ArtifactKind::parse accepts exactly: `bin` (all binaries), `cdylib`, `staticlib`, or `bin:<name>` (a specific binary). Any other artifact kind string yields this error. This parses the `artifact = \"...\"` / `artifact = [...]` field of a dependency declaration.","triggerScenarios":"Declaring a dependency with an unsupported artifact kind in Cargo.toml, e.g. `artifact = \"lib\"`, `artifact = \"dylib\"`, `artifact = \"proc-macro\"`.","commonSituations":"Assuming any crate-type is a valid artifact; typo in the kind; confusing target crate-types with dependency artifact kinds.","solutions":["Use one of the supported kinds: bin, cdylib, staticlib, or bin:<name>.","If you need a different library type, build it as a normal dependency without the artifact field.","Re-read the dependency.artifact docs to confirm supported values."],"exampleFix":"# before (Cargo.toml)\n# [dependencies]\n# foo = { version = \"1\", artifact = \"dylib\" }\n\n# after\n# [dependencies]\n# foo = { version = \"1\", artifact = \"cdylib\" }","handlingStrategy":"validation","validationCode":"fn parse_artifact_kind(kind: &str) -> Result<(), String> {\n    let ok = matches!(kind, \"bin\" | \"cdylib\" | \"staticlib\") || kind.starts_with(\"bin:\");\n    if ok { Ok(()) } else { Err(format!(\"'{kind}' is not a valid artifact specifier\")) }\n}","typeGuard":"fn is_valid_artifact_kind(kind: &str) -> bool {\n    matches!(kind, \"bin\" | \"cdylib\" | \"staticlib\") || kind.starts_with(\"bin:\")\n}","tryCatchPattern":null,"preventionTips":["Restrict artifact kinds to bin, cdylib, staticlib, or bin:<name>.","Add a manifest lint that rejects unknown artifact values before publish.","Do not confuse target crate-types (lib, rlib, dylib, proc-macro) with dependency artifact kinds."],"tags":["dependencies","artifacts","manifest","validation"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}