From a0791eef0195370f14b9d3c0a7a81d6d48182904 Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 1 Oct 2024 15:40:46 -0700 Subject: [PATCH] remap crates fetched via sparse registry as well on Rust nightlies since about 2023-03-09 (https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-168-2023-03-09) it seems the default protocol switched to "sparse". this has a side effect of caching fetched crates at a different path, so the `github.com` path remapping is no longer sufficient to normalize all crate paths. thankfully, to make it sufficient we only have to handle the new `index.crates.io-6f17d22bba15001f` path as well. this in fact is where *all* cargo-fetched crates.io dependencies end up now. technically we could forget about `github.com-1ecc6299db9ec823` at this point, but by keeping it we'll still be correct in the unlikely event someone were to flip away from `sparse` to `git` for the Cargo protocol. --- build/xtask/src/dist.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build/xtask/src/dist.rs b/build/xtask/src/dist.rs index dc35f5d1d..21e473dec 100644 --- a/build/xtask/src/dist.rs +++ b/build/xtask/src/dist.rs @@ -167,7 +167,7 @@ impl PackageConfig { remap_paths.insert(cargo_git, "/git"); // This hash is canonical-ish: Cargo tries hard not to change it - // https://github.com/rust-lang/cargo/blob/master/src/cargo/core/source/source_id.rs#L607-L630 + // https://github.com/rust-lang/cargo/blob/5dfdd59/src/cargo/core/source_id.rs#L755-L794 // // It depends on system architecture, so this won't work on (for example) // a Raspberry Pi, but the only downside is that panic messages will @@ -177,6 +177,15 @@ impl PackageConfig { .join("src") .join("github.com-1ecc6299db9ec823"); remap_paths.insert(cargo_registry, "/crates.io"); + // If Cargo uses the sparse registry (stabilized since ~1.72) it caches fetched crates + // in a slightly different path. Remap that one as well. + // + // This path has the same canonical-ish properties as above. + let cargo_sparse_registry = cargo_home + .join("registry") + .join("src") + .join("index.crates.io-6f17d22bba15001f"); + remap_paths.insert(cargo_sparse_registry, "/crates.io"); } if let Ok(dir) = std::env::var("CARGO_MANIFEST_DIR") {