bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
670 stars 433 forks source link

crate_universe renders different `MODULE.bazel.lock` on windows vs linux #2878

Open UebelAndre opened 2 months ago

UebelAndre commented 2 months ago

Noticed on https://github.com/bazelbuild/rules_rust/pull/2866, the bzlmod BCR presubmit on windows job was failing with:

(23:33:40) ERROR: Analysis of target '//:hello_world_vendored_test' failed; build aborted: MODULE.bazel.lock is no longer up-to-date because: The implementation of the extension 'ModuleExtensionId{bzlFileLabel=//third-party:extension.bzl, extensionName=crate_repositories, isolationKey=Optional.empty}' or one of its transitive .bzl files has changed. Please run `bazel mod deps --lockfile_mode=update` to update your lockfile.
(23:33:40) INFO: Elapsed time: 0.955s, Critical Path: 0.00s
(23:33:40) INFO: 1 process: 1 internal.
(23:33:40) ERROR: Build did NOT complete successfully
(23:33:40) ERROR: No test targets were found, yet testing was requested
(23:33:40) FAILED:

When the command is run on a Windows machine, the following diff is produced:

diff --git a/examples/bzlmod/hello_world/MODULE.bazel.lock b/examples/bzlmod/hello_world/MODULE.bazel.lock
index 3607ba47..9d6394a3 100644
--- a/examples/bzlmod/hello_world/MODULE.bazel.lock
+++ b/examples/bzlmod/hello_world/MODULE.bazel.lock
@@ -99,7 +99,7 @@
   "moduleExtensions": {
     "//third-party:extension.bzl%crate_repositories": {
       "general": {
-        "bzlTransitiveDigest": "i4yp7qUetvedeDhOvPj+9+Z5HfpBKTv4QPEg1cnDRSA=",
+        "bzlTransitiveDigest": "cqUx6n/ORKXs8rhE+nTohXqemXAxMv6A1y6mRnxmPhE=",
         "usagesDigest": "n26CV4cfVuxRixL8viN6C0ux4GOeMd3TcVWLDi3yEXg=",
         "recordedFileInputs": {},
         "recordedDirentsInputs": {},
@@ -2831,7 +2831,7 @@
     },
     "@@rules_rust~//crate_universe/private/module_extensions:cargo_bazel_bootstrap.bzl%cargo_bazel_bootstrap": {
       "general": {
-        "bzlTransitiveDigest": "BNk2lSmPFvhtV2uT4kYvPZC6XqgtYX6MS+wBOWpNTxk=",
+        "bzlTransitiveDigest": "7G+kRVBstF4io/kCfSVeSVfuFb9PJlHnmrFAEykEq0E=",
         "usagesDigest": "4j52H63OB19ipuXlWqw5ELkm0MSoKrHSwWb5leP5KX8=",
         "recordedFileInputs": {},
         "recordedDirentsInputs": {},
@@ -2927,7 +2927,7 @@
     },
     "@@rules_rust~//rust:extensions.bzl%rust": {
       "general": {
-        "bzlTransitiveDigest": "SqTykb9lmI/W1mnXjM79nHEoAHh0BjNsrDztK+foV3c=",
+        "bzlTransitiveDigest": "6JH7szw8e4pL95SFQIjCCR0MPssZDOKdQWuuzbrid7A=",
         "usagesDigest": "/n9pwvYUZ8UYxB543f13GdnGNL3Ml6QTEjAwNOE+bK8=",
         "recordedFileInputs": {},
         "recordedDirentsInputs": {},
@@ -6015,7 +6015,7 @@
     },
     "@@rules_rust~//rust/private:extensions.bzl%i": {
       "general": {
-        "bzlTransitiveDigest": "yaWbGvJJUd5992MNUvdpjcJmOKazeMhdsCkOQ2X22R4=",
+        "bzlTransitiveDigest": "6pDWGWNg5oMNG2orw6UPfYVg7eZw1kGPMZLW179f9n0=",
         "usagesDigest": "UNpcnQXQKPinVDqLbfIv+tb5J6eu9Z+wiU0L5bDyWDY=",
         "recordedFileInputs": {},
         "recordedDirentsInputs": {},
@@ -14247,7 +14247,7 @@
             "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
             "ruleClassName": "http_archive",
             "attributes": {
-              "build_file_content": "load(\"@rules_rust//rust:defs.bzl\", \"rust_library\")\n\nrust_library(\n    name = \"libc\",\n    srcs = glob([\"src/**/*.rs\"]),\n    edition = \"2015\",\n    rustc_flags = [\n        # In most cases, warnings in 3rd party crates are not interesting as\n        # they're out of the control of consumers. The flag here silences\n        # warnings. For more details see:\n        # https://doc.rust-lang.org/rustc/lints/levels.html\n        \"--cap-lints=allow\",\n    ],\n    visibility = [\"//visibility:public\"],\n)\n",
+              "build_file_content": "load(\"@rules_rust//rust:defs.bzl\", \"rust_library\")\r\n\r\nrust_library(\r\n    name = \"libc\",\r\n    srcs = glob([\"src/**/*.rs\"]),\r\n    edition = \"2015\",\r\n    rustc_flags = [\r\n        # In most cases, warnings in 3rd party crates are not interesting as\r\n        # they're out of the control of consumers. The flag here silences\r\n        # warnings. For more details see:\r\n        # https://doc.rust-lang.org/rustc/lints/levels.html\r\n        \"--cap-lints=allow\",\r\n    ],\r\n    visibility = [\"//visibility:public\"],\r\n)\r\n",
               "sha256": "1ac4c2ac6ed5a8fb9020c166bc63316205f1dc78d4b964ad31f4f21eb73f0c6d",
               "strip_prefix": "libc-0.2.20",
               "urls": [

Note the use of \r\n in the MODULE.bazel.lock file vs \n. These should probably be updated to always render \n.

illicitonion commented 4 weeks ago

Hopefully https://github.com/bazelbuild/rules_rust/pull/2939 fixes this? Maybe?