Skip to content

Go container image build fails on macOS in 0.23.0 (worked in 0.22.0) due to toolchain resolution #2052

@Xjs

Description

@Xjs

🐞 bug report

Affected Rule

The issue is caused by the rule: go_image

Is this a regression?

Yes, the previous version in which this bug was not present was: 0.22.0

Description

On macOS (I tested both macOS 12 on Apple Silicon and macOS 11 on Intel) go_image targets fail to build using rules_docker 0.23.0. The error message is:

ERROR: /private/var/tmp/_bazel_jannis/9dc304b8c991dee4d60914cc5c48b927/external/io_bazel_rules_go/BUILD.bazel:86:17: While resolving toolchains for target @io_bazel_rules_go//:cgo_context_data: 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.

(which is actually quite misleading). After some search I was able to pinpoint this regression to the rules_docker 0.23.0 release.

This appears to be a similar, but not exactly the same, issue as #2009.

🔬 Minimal Reproduction

The bug can be reproduced with https://github.com/Xjs/rules-docker-macos-regression .

🔥 Exception or Error


~/src/stuff/rules-docker-macos-regression> bazel build ... --define=VERBOSE_LOGS=1
WARNING: Download from https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip failed: class java.io.FileNotFoundException GET returned 404 Not Found
DEBUG: Rule 'io_bazel_rules_docker' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "85ffff62a4c22a74dbd98d05da6cf40f497344b3dbf1e1ab0a37ab2a1a6ca014"
DEBUG: Repository io_bazel_rules_docker instantiated at:
  /Users/jannis/src/stuff/rules-docker-macos-regression/WORKSPACE:32:13: in 
Repository rule http_archive defined at:
  /private/var/tmp/_bazel_jannis/9dc304b8c991dee4d60914cc5c48b927/external/bazel_tools/tools/build_defs/repo/http.bzl:353:31: in 
INFO: Build option --define has changed, discarding analysis cache.
DEBUG: Rule 'go_static' indicated that a canonical reproducible form can be obtained by modifying arguments digest = "sha256:709eb1a2c147fd064900a5e8a3ff1f03b201a36f1f2954bb9e60f4953c5f641a"
DEBUG: Repository go_static instantiated at:
  /Users/jannis/src/stuff/rules-docker-macos-regression/WORKSPACE:62:15: in 
Repository rule container_pull defined at:
  /private/var/tmp/_bazel_jannis/9dc304b8c991dee4d60914cc5c48b927/external/io_bazel_rules_docker/container/pull.bzl:278:33: in 
ERROR: /private/var/tmp/_bazel_jannis/9dc304b8c991dee4d60914cc5c48b927/external/io_bazel_rules_go/BUILD.bazel:86:17: While resolving toolchains for target @io_bazel_rules_go//:cgo_context_data: 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 '//:layer' failed; build aborted: 
INFO: Elapsed time: 3.307s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 9868 targets configured)
    Fetching @local_config_cc; Building xcode-locator
    Fetching @com_github_pkg_errors; Restarting.
    Fetching @com_github_google_go_containerregistry; Restarting.
    Fetching @bazel_gazelle_go_repository_config; Restarting.
    Fetching @bazel_gazelle_go_repository_tools; fetching
Exception: bazel exited with 1
[tty 13], line 1: bazel build ... --define=VERBOSE_LOGS=1

🌍 Your Environment

Operating System:

  
macOS 11.6.4 (on Intel Core M)
macOS 12.3 (on Apple M1)
  

Output of bazel version:

On both machines:

  
Build label: 5.1.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Mar 24 14:10:21 2022 (1648131021)
Build timestamp: 1648131021
Build timestamp as int: 1648131021
  

Rules_docker version:

  
0.23.0
  

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