Skip to content

Commit fc62ff2

Browse files
committed
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.
1 parent e38fa8c commit fc62ff2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crate_universe/src/config.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,15 @@ pub(crate) struct Config {
716716
impl Config {
717717
pub(crate) fn try_from_path<T: AsRef<Path>>(path: T) -> Result<Self> {
718718
let data = fs::read_to_string(path)?;
719-
Ok(serde_json::from_str(&data)?)
719+
let mut res: Config = serde_json::from_str(&data)?;
720+
721+
// rules_rust/crate_universe/private/generate_utils.bzl:generate_config
722+
// injects the cargo_config as a literal JSON string, this causes line ending
723+
// instability in Unix vs Windows. Parsing it here fixes any cross platform differences.
724+
if let Some(Some(config)) = res.cargo_config.as_ref().map(|v| v.as_str()) {
725+
res.cargo_config = Some(config.parse()?)
726+
}
727+
Ok(res)
720728
}
721729
}
722730

0 commit comments

Comments
 (0)