Unable to build rust images on macOS
🐞 bug report
Affected Rule
The issue seems to be triggered by calling the `_rust_image_repos()` rule. I'm not convinced that this rule is the culprit, since adding a `go` toolchain produces a different error.Is this a regression?
I'm not sure. I don't go further back than `0.21.0` and the issue was still prevalent thereDescription
It is currently not possible to build a rust docker image on macOS (12.4). You'll run into multiple issues when attempting to build. See exception for error messages for each:- You will get an error message about a missing
cpp:toolchain. This seems related to https://github.com/bazelbuild/rules_docker/issues/2075, as adding agotoolchain fixes this error but gives you a new error message - After adding a
gotoolchain you will get an error indexing into theio_bazel_rules_go. Addinggazelleseems to fix this problem. - After adding
gazelleit seems like you arrive at a dead end where therusttoolchain is missing.
🔬 Minimal Reproduction
I add a Github Repo with a minimal example. Note the branches are numbered to correspond the errors below:
🔥 Exception or Error
1:
INFO: Build option --define has changed, discarding analysis cache.
ERROR: /Users/emilio/Code/test/rust-bazel-image/rust/BUILD.bazel:3:12: While resolving toolchains for target //rust:bin: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there is no default C++ toolchain added in the WORKSPACE file? See https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions.
ERROR: Analysis of target '//rust:bin' failed; build aborted:
INFO: Elapsed time: 0.205s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 267 targets configured)
2:
ERROR: Analysis of target '//rust:bin' failed; build aborted: error loading package '@io_bazel_rules_docker//': at /private/var/tmp/_bazel_emilio/df46fc64877e15fd2a061db2455d93bd/external/bazel_gazelle/def.bzl:34:5: at /private/var/tmp/_bazel_emilio/df46fc64877e15fd2a061db2455d93bd/external/bazel_gazelle/internal/gazelle_binary.bzl:22:5: Label '@io_bazel_rules_go//go/private:rules/aspect.bzl' is invalid because '@io_bazel_rules_go//go/private/rules' is a subpackage; perhaps you meant to put the colon here: '@io_bazel_rules_go//go/private/rules:aspect.bzl'?
INFO: Elapsed time: 0.216s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (2 packages loaded, 271 targets configured)
currently loading: @io_bazel_rules_docker//
3:
ERROR: /Users/emilio/Code/test/rust-bazel-image/rust/BUILD.bazel:3:11: While resolving toolchains for target //rust:bin_binary: no matching toolchains found for types @rules_rust//rust:toolchain
ERROR: Analysis of target '//rust:bin' failed; build aborted:
INFO: Elapsed time: 4.645s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (73 packages loaded, 1357 targets configured)
🌍 Your Environment
Operating System:
macOS Monterey 12.04 (m1)
Output of bazel version:
Bazelisk version: development
Build label: 5.2.0
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 7 16:11:09 2022 (1654618269)
Build timestamp: 1654618269
Build timestamp as int: 1654618269
Rules_docker version:
0.24.0
Anything else relevant?
The issues also seems to be persistent in 0.22, so it might not be related to https://github.com/bazelbuild/rules_docker/pull/1963
I'm not sure if this issue also exists on linux since I don't have access to a Linux box
I think I'm having a similar problem, though not with rust. I'm also on macOS Monterey 12.04 (m1). If you add --toolchain_resolution_debug='rust' to your command what output do you get?
I'm having the same exact issue in the same environment.
Ditto, just ran into this as well!
I'm having this issue trying to build a python image as well:
ERROR: Analysis of target '//meltano:meltano_image' failed; build aborted: error loading package '@io_bazel_rules_docker//': at /private/var/tmp/_bazel_maarten/dd95190e1d8b839ea338f24ccfac5aac/external/bazel_gazelle/def.bzl:34:5: at /private/var/tmp/_bazel_maarten/dd95190e1d8b839ea338f24ccfac5aac/external/bazel_gazelle/internal/gazelle_binary.bzl:22:5: Label '@io_bazel_rules_go//go/private:rules/aspect.bzl' is invalid because '@io_bazel_rules_go//go/private/rules' is a subpackage; perhaps you meant to put the colon here: '@io_bazel_rules_go//go/private/rules:aspect.bzl'?
We are also affected by this issue.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"
I just got this issue as well. Since it has been closed, is there any solution for this?