Skip to content

Unable to build rust images on macOS #2108

@axrez

Description

@axrez

🐞 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 there

Description

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:
  1. You will get an error message about a missing cpp:toolchain. This seems related to py_binary stops working after adding rules_docker dependencies #2075, as adding a go toolchain fixes this error but gives you a new error message
  2. After adding a go toolchain you will get an error indexing into the io_bazel_rules_go. Adding gazelle seems to fix this problem.
  3. After adding gazelle it seems like you arrive at a dead end where the rust toolchain 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 #1963

I'm not sure if this issue also exists on linux since I don't have access to a Linux box

Metadata

Metadata

Assignees

No one assigned

    Labels

    Can Close?Will close in 30 days unless there is a comment indicating why not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions