rules_docker icon indicating copy to clipboard operation
rules_docker copied to clipboard

Unable to build rust images on macOS

Open axrez opened this issue 3 years ago • 4 comments

🐞 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 https://github.com/bazelbuild/rules_docker/issues/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 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

axrez avatar Jun 13 '22 08:06 axrez

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?

ricochet1k avatar Jun 28 '22 15:06 ricochet1k

I'm having the same exact issue in the same environment.

lukas-slezevicius avatar Aug 12 '22 12:08 lukas-slezevicius

Ditto, just ran into this as well!

trezm avatar Aug 22 '22 21:08 trezm

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'?

mvgijssel avatar Sep 16 '22 12:09 mvgijssel

We are also affected by this issue.

fmorency avatar Nov 21 '22 16:11 fmorency

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!

github-actions[bot] avatar May 21 '23 02:05 github-actions[bot]

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

github-actions[bot] avatar Jun 21 '23 02:06 github-actions[bot]

I just got this issue as well. Since it has been closed, is there any solution for this?

marmos91 avatar Jul 03 '23 12:07 marmos91