{"id":"229c881deea2421d","repo":"rust-lang/cargo","slug":"missing-crate-name-for-v","errorCode":null,"errorMessage":"missing crate name for `@{v}`","messagePattern":"missing crate name for `@(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bin/cargo/commands/yank.rs","lineNumber":59,"sourceCode":"        version.map(|s| s.to_string()),\n        args.get_one::<String>(\"token\").cloned().map(Secret::from),\n        args.registry_or_index(gctx)?,\n        args.flag(\"undo\"),\n    )?;\n    Ok(())\n}\n\nfn resolve_crate<'k>(\n    mut krate: Option<&'k str>,\n    mut version: Option<&'k str>,\n) -> crate::CargoResult<(Option<&'k str>, Option<&'k str>)> {\n    if let Some((k, v)) = krate.and_then(|k| k.split_once('@')) {\n        if version.is_some() {\n            anyhow::bail!(\"cannot specify both `@{v}` and `--version`\");\n        }\n        if k.is_empty() {\n            // by convention, arguments starting with `@` are response files\n            anyhow::bail!(\"missing crate name for `@{v}`\");\n        }\n        krate = Some(k);\n        version = Some(v);\n    }\n\n    if let Some(version) = version {\n        semver::Version::parse(version).with_context(|| {\n            if let Some(stripped) = version.strip_prefix(\"v\") {\n                return format!(\n                    \"the version provided, `{version}` is not a \\\n                    valid SemVer version\\n\\n\\\n                    help: try changing the version to `{stripped}`\",\n                );\n            }\n            format!(\"invalid version `{version}`\")\n        })?;\n    }\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/bin/cargo/commands/yank.rs#L41-L77","documentation":"In resolve_crate (yank.rs:57-60), when the crate argument starts with `@` (i.e. split_once('@') yields an empty left side), the crate name is missing. By Cargo convention a leading `@` denotes a response file, so a bare `@version` is treated as a crate-less spec and rejected.","triggerScenarios":"Running `cargo yank @1.2.3` (version given but no crate name before the `@`).","commonSituations":"Forgetting the crate name; assuming `--version` style works positionally as `@version`; shell expansion that dropped the crate token.","solutions":["Provide the crate name: `cargo yank mycrate@1.2.3` or `cargo yank mycrate --version 1.2.3`.","If you intended a response file, use a real `@file` argument to a subcommand that supports it — `yank` does not."],"exampleFix":"// before\n$ cargo yank @1.2.3\nerror: missing crate name for `@1.2.3`\n\n// after\n$ cargo yank mycrate@1.2.3","handlingStrategy":"validation","validationCode":"if let Some(spec) = &crate_arg {\n    if spec.starts_with('@') {\n        return Err(\"missing crate name before @; use crate@version\");\n    }\n}","typeGuard":"fn has_crate_before_at(spec: &str) -> bool {\n    match spec.split_once('@') {\n        Some((k, _)) => !k.is_empty(),\n        None => true,\n    }\n}\n","tryCatchPattern":null,"preventionTips":["Always write the crate name before @ when using inline version.","Sanitize yank args in scripts to ensure a non-empty crate token."],"tags":["cargo","yank","publish","cli","argument"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}