rust-lang/cargo · error · anyhow::Error

found an override with a non-locked list

Error message

found an override with a non-locked list

What it means

Error "found an override with a non-locked list" thrown in rust-lang/cargo.

Source

Thrown at src/workspace/registry.rs:795

                    return Err(anyhow::anyhow!("found patches and a path override"));
                }
                let mut n = 0;
                let mut to_warn = None;
                let callback = &mut |summary| {
                    n += 1;
                    match summary {
                        IndexSummary::Candidate(summary)
                        | IndexSummary::Yanked(summary)
                        | IndexSummary::Offline(summary)
                        | IndexSummary::Unsupported(summary, _)
                        | IndexSummary::Invalid(summary) => {
                            to_warn = Some(summary);
                        }
                    }
                };
                query_with_context(&*source, dep, kind, callback).await?;
                if n > 1 {
                    return Err(anyhow::anyhow!("found an override with a non-locked list"));
                }
                if let Some(to_warn) = to_warn {
                    self.warn_bad_override(&override_summary, &to_warn)?;
                }
                let override_summary = self.lock(override_summary);
                f(IndexSummary::Candidate(override_summary));
            }
        }

        Ok(())
    }

    fn describe_source(&self, id: SourceId) -> String {
        match self.sources.borrow().get(id) {
            Some(src) => src.describe(),
            None => id.to_string(),
        }
    }

View on GitHub (pinned to 0e07a15537)

Solutions

  1. Commit/update Cargo.lock so the lock file exists before using an override.
  2. Remove the override if a locked dependency list is not available.

When it happens

Trigger: Thrown at src/workspace/registry.rs:795 when the library encounters an invalid state.

Common situations: Occurs when a directory/registry override is used together with a lock file that does not lock the override source. Avoid combining `paths` overrides with locked resolution, or update the lock file accordingly.


AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06). Data as JSON: /data/errors/2de7bd13e4a932b5.json. Report an issue: GitHub.