-
Notifications
You must be signed in to change notification settings - Fork 439
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
Linux cargo binary selected on Mac OS (Darwin) with bzlmod #2549
Comments
I'm getting the same but somehow inverted. I'm running
and in the Bazel output I see it's extracting However, all of the following seem to resolve the problem:
So I suspect there is some nondeterminism going on. |
I tried again and again, even with our Docker cache mounts disabled, and the following delta in rules_rust already seems enough to mitigate the issue for me. Reliably, with this patch our build works, and without it doesn't. Bizarre. This is from a Debian image with some packages installed, users configured, and ssh configured. (By the way I'm using Bazelisk 1.15.0 and Bazel 7.1.0rc1, not that I imagine that matters.) --- a/rust/private/repository_utils.bzl
+++ b/rust/private/repository_utils.bzl
@@ -727,6 +727,8 @@ def load_arbitrary_tool(ctx, tool_name, tool_subdirectories, version, iso_date,
sha256 = lookup_tool_sha256(ctx, tool_name, target_triple, version, iso_date, sha256)
+ print("Going to download", sha256, "for urls", urls)
+
for subdirectory in tool_subdirectories:
# As long as the sha256 value is consistent accross calls here the
# cost of downloading an artifact is negated as by Bazel's caching. |
Upgrading Bazel to 7.1.1rc1 did not work for me, but regressing to 7.0.2 did also 'fix' the issue. |
We just ran into this as well. I believe this is a duplicate of #2452. Hopefully the fix for that will get in soon. |
Im seeing this as well, but its working on |
Any workarounds? I'm facing the same issue. |
Yeah, just kill your lockfile and the resolution should happen again fresh. I usually change the file to contain |
This may be addressed as of 0.41.0. See #2452 (comment). |
I tried it with version
The "@@rules_rust~//rust:extensions.bzl%rust": {
"general": {
"bzlTransitiveDigest": "fuThwhlVrMVy1jd24+jEAspC7bT8RhfezJA1i8Pgw8c=",
@@ -4176,8 +5926,8 @@
"bzlFile": "@@rules_rust~//rust:repositories.bzl",
"ruleClassName": "rust_toolchain_tools_repository",
"attributes": {
- "exec_triple": "aarch64-apple-darwin",
- "target_triple": "aarch64-apple-darwin",
+ "exec_triple": "x86_64-unknown-linux-gnu",
+ "target_triple": "x86_64-unknown-linux-gnu",
"allocator_library": "@rules_rust//ffi/cc/allocator_library",
"dev_components": false,
"edition": "2021", |
Did you update bazel to 7.1? Im currently committing the lock to our CI and it works in CI as well on (x86_64 linux / arm64 linux (ci) / arm64 darwin). |
Okay follow up here, it is not resolved. It looks like it resolved the deps being tied to the triple, but not the toolchains. |
We are on bazel version I assume that you committed your Just to be sure, on the branch I deleted the For the version that works on Mac OS: ❯ grep -A 17 '"rust_host_tools": {' MODULE.bazel.lock
"rust_host_tools": {
"bzlFile": "@@rules_rust~//rust:repositories.bzl",
"ruleClassName": "rust_toolchain_tools_repository",
"attributes": {
"exec_triple": "aarch64-apple-darwin",
"target_triple": "aarch64-apple-darwin",
"allocator_library": "@rules_rust//ffi/cc/allocator_library",
"dev_components": false,
"edition": "2021",
"rustfmt_version": "nightly/2024-03-21",
"sha256s": {},
"urls": [
"https://static.rust-lang.org/dist/{}.tar.xz"
],
"version": "1.77.0",
"iso_date": ""
}
}, ❯ grep -A 17 '"rust_host_tools": {' MODULE.bazel.lock
"rust_host_tools": {
"bzlFile": "@@rules_rust~//rust:repositories.bzl",
"ruleClassName": "rust_toolchain_tools_repository",
"attributes": {
"exec_triple": "x86_64-unknown-linux-gnu",
"target_triple": "x86_64-unknown-linux-gnu",
"allocator_library": "@rules_rust//ffi/cc/allocator_library",
"dev_components": false,
"edition": "2021",
"rustfmt_version": "nightly/2024-03-21",
"sha256s": {},
"urls": [
"https://static.rust-lang.org/dist/{}.tar.xz"
],
"version": "1.77.0",
"iso_date": ""
}
}, @ericmcbride I wonder what it looks like in your config. |
Yes this is exactly what mine looks like as well |
@cameron-martin looks like your work in #2453 (comment) is still needed! |
Right, I didn't notice that #2575 changed a totally different module extension, so this will still be an issue. |
Since the host tools are os and arch specific, previously bazel would cache the resolution of these in the lock file, causing the repo for the wrong OS or arch to be used when moving between machines. Since bazel 7.1.0, module extensions can be marked as reproducible to exclude these from the lock file. However, the `rust` module extension handles fetching of all the other toolchains as well as the host tools, and we don't really want to exclude those too. Therefore the host tools are moved to their own module extension. This means we can no longer match the host toolchain's version, edition, etc with the toolchain registered via `rust.toolchain` by default, and instead default to a fixed version. This can still be overridden separately in the root module. I think this is okay, because the host tools are only used for bootstrapping and I don't think there's much need to have them match. This is tested by now checking in the MODULE.bazel.lock file of the bzlmod example, and running the bzlmod examples on multiple platforms with `--lockfile_mode` set to `error`. Resolves #2452 Resolves #2549
Heyo, just checked with the latest release and it works :) Thank you, @cameron-martin and @illicitonion ! |
After switching version rules_rust
0.4.0
fromWORKSPACE
toMODULE.bazel
on Bazel 7.1.0, we get the following error on Darwin:Weirdly enough it seems to provision a Linux binary here:
Of course, chances are that we are just doing it wrong!
This is what we use in
WORKSPACE
(working):This is what we tried in
MODULE.bazel
(leading to the error above):The text was updated successfully, but these errors were encountered: