{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/workspace/dependency.rs","lineNumber":654,"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":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/workspace/dependency.rs#L636-L672","documentation":"ArtifactKind::parse accepts exactly `bin`, `cdylib`, `staticlib`, or `bin:<name>`. Anything else falls through; it tries to strip a `bin:` prefix and, on failure, returns this error. Artifact specifiers appear in a dependency's `artifact = [...]` list (RFC 3452 DEP-cargo-artifacts), selecting which build artifacts to depend on.","triggerScenarios":"Writing a Cargo.toml dependency with an artifact string that is not one of the recognized forms, e.g. `artifact = ['dylib']` (should be `cdylib`), `artifact = ['exe']`, `artifact = ['bin:']` (empty name), or a typo like `artifact = ['bins']`.","commonSituations":"Typing the artifact kind from memory (e.g. `dylib` instead of `cdylib`, `exe`/`binary` instead of `bin`); forgetting the `bin:` prefix when selecting a named binary (`artifact = ['mybin']`); trailing characters or whitespace.","solutions":["Use one of the valid kinds: `bin`, `cdylib`, `staticlib`, or `bin:<binary-name>`.","For a named binary use the `bin:` prefix: `artifact = [\"bin:mybin\"]`.","Remove typos/whitespace and check spelling against the RFC 3452 artifact list."],"exampleFix":"# Cargo.toml before\n[dependencies.mycrate]\nartifact = [\"dylib\"]\n\n# after\n[dependencies.mycrate]\nartifact = [\"cdylib\"]","handlingStrategy":"validation","validationCode":"fn validate_artifact_kind(kind: &str) -> Result<(), String> {\n    match kind {\n        \"bin\" | \"cdylib\" | \"staticlib\" => Ok(()),\n        k if k.starts_with(\"bin:\") && k.len() > 4 => Ok(()),\n        other => Err(format!(\"'{other}' is not a valid artifact specifier; use bin | cdylib | staticlib | bin:<name>\")),\n    }\n}","typeGuard":"fn is_valid_artifact_kind(s: &str) -> bool {\n    matches!(s, \"bin\" | \"cdylib\" | \"staticlib\")\n        || (s.starts_with(\"bin:\") && s.len() > 4)\n}","tryCatchPattern":"match ArtifactKind::parse(kind) {\n    Err(e) if e.to_string().contains(\"not a valid artifact specifier\") => {\n        eprintln!(\"use one of: bin, cdylib, staticlib, bin:<name>\");\n        return Err(e);\n    }\n    r => r,\n}","preventionTips":["Remember `cdylib`/`staticlib` (not `dylib`/`lib`) and `bin` (not `exe`/`binary`).","Always prefix named binaries with `bin:`.","Add a manifest linter (toml schema check) for the `artifact` array."],"tags":["manifest","artifact","dependency","validation","toml"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}