Skip to content

Commit 253fab1

Browse files
committed
Auto merge of #9476 - ehuss:index-cache-bump, r=alexcrichton
Bump index cache version to deal with semver metadata version mismatch. #9467 has uncovered an issue with how versions are handled in the index cache. When using a debug build of Cargo, it may panic due to the [cache contents changing](https://github.com/rust-lang/cargo/blob/5c455130b6001c7f54e872e161c27f6e996aff1f/src/cargo/sources/registry/index.rs#L606-L619). The particular problem I am running into is that the index has an entry for `openssl-src 110.0.0` and `110.0.0+1.1.0f`. This is due to an issue with crates.io where it allows publishing multiple versions with the same metadata (rust-lang/crates.io#1059). Cargos before #9467 would populate the index cache with two entries, both with version `110.0.0`. Afterwards, there are two separate entries (`110.0.0` and `110.0.0+1.1.0f`). The change here is to bump the index cache version so that new versions of cargo will clear the cache, and won't trigger the assertion. This may be a bit of a heavy-handed solution, as I think this only affects debug builds of cargo. However, I instantly started running into this problem, so I suspect it will be a real annoyance for anyone developing cargo. Happy to discuss other possible solutions.
2 parents e5fdd48 + 7d0c068 commit 253fab1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/cargo/sources/registry/index.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,16 @@ impl Summaries {
692692
// * `2`: Added the "index format version" field so that if the index format
693693
// changes, different versions of cargo won't get confused reading each
694694
// other's caches.
695-
696-
const CURRENT_CACHE_VERSION: u8 = 2;
695+
// * `3`: Bumped the version to work around a issue where multiple versions of
696+
// a package were published that differ only by semver metadata. For
697+
// example, openssl-src 110.0.0 and 110.0.0+1.1.0f. Previously, the cache
698+
// would be incorrectly populated with two entries, both 110.0.0. After
699+
// this, the metadata will be correctly included. This isn't really a format
700+
// change, just a version bump to clear the incorrect cache entries. Note:
701+
// the index shouldn't allow these, but unfortunately crates.io doesn't
702+
// check it.
703+
704+
const CURRENT_CACHE_VERSION: u8 = 3;
697705

698706
impl<'a> SummariesCache<'a> {
699707
fn parse(data: &'a [u8], last_index_update: &str) -> CargoResult<SummariesCache<'a>> {

0 commit comments

Comments
 (0)