Skip to content

Commit 12598a6

Browse files
authored
Fixed crate_universe when using Rust >= 1.85.0 (bazelbuild#3251)
This change uses frewsxcv/rust-crates-index#184 to fix issues around locating crate files.
1 parent acac3e5 commit 12598a6

File tree

17 files changed

+192
-61
lines changed

17 files changed

+192
-61
lines changed

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ use_repo(
9696
"cui",
9797
"cui__anyhow-1.0.95",
9898
"cui__camino-1.1.9",
99-
"cui__cargo-lock-10.0.1",
99+
"cui__cargo-lock-10.1.0",
100100
"cui__cargo-platform-0.1.9",
101101
"cui__cargo_metadata-0.19.1",
102102
"cui__cargo_toml-0.21.0",
103103
"cui__cfg-expr-0.17.2",
104104
"cui__clap-4.5.26",
105-
"cui__crates-index-3.5.0",
105+
"cui__crates-index-3.6.0",
106106
"cui__glob-0.3.2",
107107
"cui__hex-0.4.3",
108108
"cui__indoc-2.0.5",

crate_universe/3rdparty/crates/BUILD.bazel

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/3rdparty/crates/BUILD.cargo-lock-10.0.1.bazel renamed to crate_universe/3rdparty/crates/BUILD.cargo-lock-10.1.0.bazel

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/3rdparty/crates/BUILD.crates-index-3.5.0.bazel renamed to crate_universe/3rdparty/crates/BUILD.crates-index-3.6.0.bazel

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/3rdparty/crates/BUILD.rustc-stable-hash-0.1.1.bazel

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/3rdparty/crates/defs.bzl

Lines changed: 24 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/Cargo.lock

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ anyhow = "1.0.95"
6565
camino = "1.1.9"
6666
cargo_metadata = "0.19.1"
6767
cargo_toml = "0.21.0"
68-
cargo-lock = "10.0.1"
68+
cargo-lock = "10.1.0"
6969
cargo-platform = "0.1.9"
7070
cfg-expr = "0.17.2"
7171
clap = { version = "4.5.26", features = ["derive", "env"] }
72-
crates-index = { version = "3.5.0", default-features = false, features = [
72+
crates-index = { version = "3.6.0", default-features = false, features = [
7373
"git",
7474
] }
7575
hex = "0.4.3"

crate_universe/src/metadata.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ impl LockGenerator {
220220

221221
// Ensure the Cargo cache is up to date to simulate the behavior
222222
// of having just generated a new one
223+
tracing::debug!("Fetching crates for {}", manifest_path);
223224
let output = self
224225
.cargo_bin
225226
.command()?
@@ -230,6 +231,7 @@ impl LockGenerator {
230231
.arg("fetch")
231232
.arg("--manifest-path")
232233
.arg(manifest_path.as_std_path())
234+
.arg("--verbose")
233235
.output()
234236
.context(format!(
235237
"Error running cargo to fetch crates '{}'",
@@ -244,6 +246,14 @@ impl LockGenerator {
244246
output.status
245247
))
246248
}
249+
tracing::trace!(
250+
"Cargo fetch stderr:\n{}",
251+
String::from_utf8_lossy(&output.stderr)
252+
);
253+
tracing::trace!(
254+
"Cargo fetch stdout:\n{}",
255+
String::from_utf8_lossy(&output.stdout)
256+
);
247257
} else {
248258
debug!("Generating new lockfile");
249259
// Simply invoke `cargo generate-lockfile`

crate_universe/src/metadata/cargo_bin.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ impl Cargo {
117117
bail!("Couldn't parse cargo version");
118118
}
119119

120+
/// Determine if Cargo is on a version which uses new hashing behavior
121+
/// introduced in Rust 1.86.0. For details see <https://github.com/frewsxcv/rust-crates-index/issues/182>
122+
pub(crate) fn uses_stable_registry_hash(&self) -> Result<bool> {
123+
let full_version = self.full_version()?;
124+
let version_str = full_version.split(' ').nth(1);
125+
if let Some(version_str) = version_str {
126+
let version = Version::parse(version_str).context("Failed to parse cargo version")?;
127+
return Ok(version.major >= 1 && version.minor >= 85);
128+
}
129+
bail!("Couldn't parse cargo version");
130+
}
131+
120132
fn env(&self) -> Result<BTreeMap<String, OsString>> {
121133
let mut map = BTreeMap::new();
122134

0 commit comments

Comments
 (0)