From fc62ff2523fc106b0f6e6390d21268950d085282 Mon Sep 17 00:00:00 2001 From: Timothy Bess Date: Fri, 23 May 2025 15:07:29 -0400 Subject: [PATCH] Fix Windows CRLF Issue Cargo configs are injected as a literal string which, on Windows, can end up with escaped CRLF line endings in cargo-bazel.json causing the digests to be different on mac/windows. This parses the inner string literal to prevent platform specific differences. --- crate_universe/src/config.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crate_universe/src/config.rs b/crate_universe/src/config.rs index 5f9b14822e..c635de3e5d 100644 --- a/crate_universe/src/config.rs +++ b/crate_universe/src/config.rs @@ -716,7 +716,15 @@ pub(crate) struct Config { impl Config { pub(crate) fn try_from_path>(path: T) -> Result { let data = fs::read_to_string(path)?; - Ok(serde_json::from_str(&data)?) + let mut res: Config = serde_json::from_str(&data)?; + + // rules_rust/crate_universe/private/generate_utils.bzl:generate_config + // injects the cargo_config as a literal JSON string, this causes line ending + // instability in Unix vs Windows. Parsing it here fixes any cross platform differences. + if let Some(Some(config)) = res.cargo_config.as_ref().map(|v| v.as_str()) { + res.cargo_config = Some(config.parse()?) + } + Ok(res) } }