{"record":{"id":"f30b7894b2f37ff9","repo":"rust-lang/cargo","slug":"patch-location-does-not-contain-packages-matc","errorCode":null,"errorMessage":"patch location `{}` does not contain packages matching `{}`\nhelp: check `{}` patch definition for `{}` in `{}`","messagePattern":"patch location `(.+?)` does not contain packages matching `(.+?)`\nhelp: check `(.+?)` patch definition for `(.+?)` in `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/workspace/registry.rs","lineNumber":1062,"sourceCode":"        });\n    let mut vers = name_summaries\n        .iter()\n        .filter_map(|s| match s {\n            IndexSummary::Candidate(s) => Some(s.version()),\n            _ => None,\n        })\n        .collect::<Vec<_>>();\n    let found = match vers.len() {\n        0 => \"\".to_string(),\n        1 => format!(\"version `{}`\", vers[0]),\n        _ => {\n            vers.sort();\n            let strs: Vec<_> = vers.into_iter().map(|v| v.to_string()).collect();\n            format!(\"versions `{}`\", strs.join(\", \"))\n        }\n    };\n    Err(if found.is_empty() {\n        anyhow::anyhow!(\n            \"patch location `{}` does not contain packages matching `{}`\\n\\\n            help: check `{}` patch definition for `{}` in `{}`\",\n            &original_patch.dep.source_id(),\n            &original_patch.dep.package_name(),\n            &original_patch.dep.package_name(),\n            orig_patch_url,\n            original_patch.loc\n        )\n    } else {\n        anyhow::anyhow!(\n            \"patch `{}` version mismatch\\n\\\n            note: patch location contains {}, but patch definition requires `{}`\\n\\\n            help: check patch location `{}`\\n\\\n            help: check `{}` patch definition for `{}` in `{}`\",\n            &original_patch.dep.package_name(),\n            found,\n            &original_patch.dep.version_req(),\n            &original_patch.dep.source_id(),","sourceCodeStart":1044,"sourceCodeEnd":1080,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/workspace/registry.rs#L1044-L1080","documentation":"The `[patch]` target source contains zero packages matching the patched dependency name. After collecting available versions (`vers`), if `found.is_empty()` the registry bails: the patch points at a source that has no crate by that name. This is the `found.is_empty()` branch at registry.rs:1040.","triggerScenarios":"`[patch.crates-io] foo = { git = \"https://...\" }` but the git repo has no package named `foo` (typo, wrong repo, or the crate was renamed/removed).","commonSituations":"Typo in the package name or repo URL. Pointing a patch at a repo that hosts a differently-named crate. The upstream crate was renamed but the patch still uses the old name.","solutions":["Verify the package name in the patch exactly matches a package in the target source.","Check the patch URL/path is correct and the source is reachable.","If the crate was renamed, update the patch key and dependency to the new name."],"exampleFix":"# before\n[patch.crates-io]\nfoo = { git = \"https://example.com/wrong-repo\" }\n\n# after\n[patch.crates-io]\nfoo = { git = \"https://example.com/correct-repo\" }","handlingStrategy":"validation","validationCode":"// Confirm the target source actually contains the named package\nfn patch_source_has_package(available_names: &[&str], patched_name: &str) -> bool {\n    available_names.iter().any(|n| *n == patched_name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the patch URL/path hosts a crate with the exact patched name.","Watch for crate renames; update both dep and patch keys.","Clone the patch source and run `cargo metadata` to list package names."],"tags":["cargo","patch","registry","source-resolution","config"],"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"}