Skip to content

Fix Windows CRLF Issue#3455

Merged
illicitonion merged 1 commit intobazelbuild:mainfrom
timbess:bugfix/cargo-home-crlf
Feb 8, 2026
Merged

Fix Windows CRLF Issue#3455
illicitonion merged 1 commit intobazelbuild:mainfrom
timbess:bugfix/cargo-home-crlf

Conversation

@timbess
Copy link
Contributor

@timbess timbess commented May 27, 2025

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 Linux/Windows. This PR parses the inner string literal to prevent platform specific differences in the config.toml. There might be a better way to do this, but adding a new top level command to cargo-bazel to parse TOML into JSON felt wrong, and adding a second binary seems even worse. I'm open to solving this another way if ya'll have a better idea.

@google-cla
Copy link

google-cla bot commented May 27, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@timbess timbess force-pushed the bugfix/cargo-home-crlf branch from 97acdf2 to fc62ff2 Compare May 27, 2025 16:52
@timbess timbess mentioned this pull request Aug 7, 2025
@timbess
Copy link
Contributor Author

timbess commented Nov 11, 2025

@UebelAndre Not sure who to ask about this, are there any changes required to get this merged? I'm just checking back in so we can hopefully delete our patch soon.

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, about the delay! How does this fix the issue?

@timbess
Copy link
Contributor Author

timbess commented Nov 12, 2025

@UebelAndre

Previously the cargo config was stored as a Value::String(... literal file contents). Parsing the inner String into a Value removes the platform specific line endings which caused Windows/Unix to have diverging digests. It would probably be cleaner to parse the TOML into JSON earlier on, but that's done in Starlark so it was a lot easier to handle this in Rust while parsing the config. I'm open to suggestions for better alternatives, but this does fix the issue on our Windows build.

@timbess timbess requested a review from UebelAndre November 13, 2025 18:24
@timbess
Copy link
Contributor Author

timbess commented Jan 15, 2026

@UebelAndre Sorry to ping you again, but just wanted to check in and see if you had any thoughts.

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the ping (I unfortunately need them)! Can you add a regression test for this? I suspect this is something that will change over time and with changes such as bazelbuild/bazel#27659 might make doing things in starlark more efficient.

@timbess timbess force-pushed the bugfix/cargo-home-crlf branch 5 times, most recently from 313a91d to e9780e0 Compare January 24, 2026 02:36
@timbess timbess requested a review from UebelAndre January 24, 2026 02:40
@timbess
Copy link
Contributor Author

timbess commented Jan 24, 2026

That's cool! Native TOML parsing in Bazel would definitely make this much easier. I added a test that I confirmed fails to replicate the digest without my change.

@timbess
Copy link
Contributor Author

timbess commented Jan 26, 2026

@UebelAndre Sorry forgot to tag you in my comment. I added a test to ensure Windows/Unix line endings don't change the digest.

@timbess timbess force-pushed the bugfix/cargo-home-crlf branch from e9780e0 to defcca5 Compare January 26, 2026 22:28
@timbess timbess force-pushed the bugfix/cargo-home-crlf branch from 1856d93 to f7b40e4 Compare February 5, 2026 03:01
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.
@timbess timbess force-pushed the bugfix/cargo-home-crlf branch from f7b40e4 to b071768 Compare February 5, 2026 03:04
Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test!

@illicitonion illicitonion dismissed UebelAndre’s stale review February 8, 2026 21:46

Comments addressed

@illicitonion illicitonion added this pull request to the merge queue Feb 8, 2026
Merged via the queue into bazelbuild:main with commit 2c3469e Feb 8, 2026
3 checks passed
@timbess timbess deleted the bugfix/cargo-home-crlf branch February 8, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments