Skip to content

Fix Windows CRLF Issue #3455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crate_universe/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,15 @@ pub(crate) struct Config {
impl Config {
pub(crate) fn try_from_path<T: AsRef<Path>>(path: T) -> Result<Self> {
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)
}
}

Expand Down