{"record":{"id":"23d5f9c73b5311fb","repo":"rust-lang/cargo","slug":"found-patches-and-a-path-override","errorCode":null,"errorMessage":"found patches and a path override","messagePattern":"found patches and a path override","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/workspace/registry.rs","lineNumber":797,"sourceCode":"                let callback = &mut |summary: IndexSummary| {\n                    for patch in patches.iter() {\n                        let patch = patch.package_id().version();\n                        if summary.package_id().version() == patch {\n                            return;\n                        }\n                    }\n                    let summary =\n                        summary.map_summary(|summary| lock(locked, all_patches, summary, mode));\n                    f(summary)\n                };\n                return query_with_context(&*source, dep, kind, callback).await;\n            }\n\n            // If we have an override summary then we query the source to sanity check its results.\n            // We don't actually use any of the summaries it gives us though.\n            (Some(override_summary), Some(source)) => {\n                if !patches.is_empty() {\n                    return Err(anyhow::anyhow!(\"found patches and a path override\"));\n                }\n                let mut n = 0;\n                let mut to_warn = None;\n                let callback = &mut |summary| {\n                    n += 1;\n                    match summary {\n                        IndexSummary::Candidate(summary)\n                        | IndexSummary::Yanked(summary)\n                        | IndexSummary::Offline(summary)\n                        | IndexSummary::Unsupported(summary, _)\n                        | IndexSummary::Invalid(summary) => {\n                            to_warn = Some(summary);\n                        }\n                    }\n                };\n                query_with_context(&*source, dep, kind, callback).await?;\n                if n > 1 {\n                    return Err(anyhow::anyhow!(\"found an override with a non-locked list\"));","sourceCodeStart":779,"sourceCodeEnd":815,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/workspace/registry.rs#L779-L815","documentation":"A dependency cannot simultaneously have `[patch]` entries and a path override — these are two distinct override mechanisms that conflict. In the `(Some(override_summary), Some(source))` arm, the registry checks `if !patches.is_empty()` and bails at registry.rs:779. Cargo refuses to mix the two to avoid ambiguous resolution semantics.","triggerScenarios":"The lock file or workspace config supplies a path override for a source while a `[patch]` table also redirects the same dependency. Both `override_summary` and a non-empty `patches` vector reach the arm.","commonSituations":"Layering `[patch]` on top of a pre-existing `[replace]`/override workflow. Partial migration from `[replace]` (deprecated) to `[patch]`. Local dev overrides colliding with CI patch tables.","solutions":["Pick one override mechanism: use `[patch]` and remove path overrides, or vice-versa.","Migrate fully to `[patch]` (the supported mechanism) and delete `[replace]`/override entries.","Run `cargo update` after consolidating to refresh resolution."],"exampleFix":"# before: both override and patch present\n[replace]\n'foo:1.0.0' = { path = '../foo-override' }\n[patch.crates-io]\nfoo = { git = 'https://example.net/foo-fork' }\n\n# after: patch only\n[patch.crates-io]\nfoo = { git = 'https://example.net/foo-fork' }","handlingStrategy":"validation","validationCode":"fn has_no_patch_override_conflict(has_patch: bool, has_override: bool) -> bool {\n    !(has_patch && has_override)\n}\n// detect both a `[patch]` table and a `[replace]`/path override for the same dep","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Migrate fully from `[replace]` to `[patch]`; do not mix.","Document the chosen override mechanism in the repo.","Remove path overrides before adding `[patch]` for the same crate."],"tags":["cargo","registry","override","patch","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"}