Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Unable to build rust images on macOS #2108

Closed
axrez opened this issue Jun 13, 2022 · 8 comments
Closed

Unable to build rust images on macOS #2108

axrez opened this issue Jun 13, 2022 · 8 comments
Labels
Can Close? Will close in 30 days unless there is a comment indicating why not

Comments

@axrez
Copy link

axrez commented Jun 13, 2022

🐞 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

@ricochet1k
Copy link

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?

@lukas-slezevicius
Copy link

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

@trezm
Copy link

trezm commented Aug 22, 2022

Ditto, just ran into this as well!

@mvgijssel
Copy link

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

@fmorency
Copy link

We are also affected by this issue.

@github-actions
Copy link

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 github-actions bot added the Can Close? Will close in 30 days unless there is a comment indicating why not label May 21, 2023
@github-actions
Copy link

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

@marmos91
Copy link

marmos91 commented Jul 3, 2023

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Can Close? Will close in 30 days unless there is a comment indicating why not
Projects
None yet
Development

No branches or pull requests

7 participants