rules_docker icon indicating copy to clipboard operation
rules_docker copied to clipboard

An error occurred during the fetch of repository 'go_image_base': Bad CPU type in executable

Open clohr-vc opened this issue 3 years ago • 4 comments

🐞 bug report

Affected Rule

The issue is caused by the rule: go_image

Is this a regression?

Unknown.

Description

Following the guides outlined in the README and trying to build the target fails.

🔬 Minimal Reproduction

With the following directory layout:

- cmd
  - gateway
    - main.go
    - BUILD.bazel
- WORKSPACE.bazel 
# BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")

go_library(
    name = "gateway_lib",
    srcs = ["main.go"],
    importpath = "gitlab.com/grp/prjct/cmd/gateway",
    visibility = ["//visibility:private"],
    deps = ["//internal/app/gateway"],
)

go_binary(
    name = "gateway",
    embed = [":gateway_lib"],
    visibility = ["//visibility:public"],
)

go_image(
    name = "container",
    srcs = ["main.go"],
    deps = ["//internal/app/gateway"],
    importpath = "gitlab.com/grp/prjct/cmd/gateway",
)

bazel build --@io_bazel_rules_docker//transitions:enable=false --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 --define=VERBOSE_LOGS=1 //cmd/gateway:container

🔥 Exception or Error





❯ bazel build --@io_bazel_rules_docker//transitions:enable=false --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 --define=VERBOSE_LOGS=1 //cmd/gateway:container
INFO: Repository go_image_base instantiated at:
  /Users/cl/src/WORKSPACE.bazel:2992:16: in 
  /private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/io_bazel_rules_docker/go/image.bzl:50:23: in repositories
Repository rule container_pull defined at:
  /private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/io_bazel_rules_docker/container/pull.bzl:294:33: in 
ERROR: An error occurred during the fetch of repository 'go_image_base':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/io_bazel_rules_docker/container/pull.bzl", line 240, column 13, in _impl
		fail("Pull command failed: %s (%s)" % (result.stderr, " ".join([str(a) for a in args])))
Error in fail: Pull command failed: src/main/tools/process-wrapper-legacy.cc:80: "execvp(/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_puller_darwin/file/downloaded, ...)": Bad CPU type in executable
 (/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_puller_darwin/file/downloaded -directory /private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_image_base/image -os linux -os-version  -os-features  -architecture amd64 -variant  -features  -name gcr.io/distroless/base@sha256:0530d193888bcd7bd0376c8b34178ea03ddb0b2b18caf265135b6d3a393c8d05)
ERROR: /Users/cl/src/WORKSPACE.bazel:2992:16: fetching container_pull rule //external:go_image_base: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/io_bazel_rules_docker/container/pull.bzl", line 240, column 13, in _impl
		fail("Pull command failed: %s (%s)" % (result.stderr, " ".join([str(a) for a in args])))
Error in fail: Pull command failed: src/main/tools/process-wrapper-legacy.cc:80: "execvp(/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_puller_darwin/file/downloaded, ...)": Bad CPU type in executable
 (/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_puller_darwin/file/downloaded -directory /private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_image_base/image -os linux -os-version  -os-features  -architecture amd64 -variant  -features  -name gcr.io/distroless/base@sha256:0530d193888bcd7bd0376c8b34178ea03ddb0b2b18caf265135b6d3a393c8d05)
ERROR: /Users/cl/src/cmd/gateway/BUILD.bazel:18:9: //cmd/gateway:container depends on @go_image_base//image:image in repository @go_image_base which failed to fetch. no such package '@go_image_base//image': Pull command failed: src/main/tools/process-wrapper-legacy.cc:80: "execvp(/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_puller_darwin/file/downloaded, ...)": Bad CPU type in executable
 (/private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_puller_darwin/file/downloaded -directory /private/var/tmp/_bazel_cl/dfdcde57cfdfc2bfd66281f8343b512e/external/go_image_base/image -os linux -os-version  -os-features  -architecture amd64 -variant  -features  -name gcr.io/distroless/base@sha256:0530d193888bcd7bd0376c8b34178ea03ddb0b2b18caf265135b6d3a393c8d05)
ERROR: Analysis of target '//cmd/gateway:container' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.256s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (2 packages loaded, 3 targets configured)


🌍 Your Environment

Operating System:

  
MacOS 12.4 (M1 Pro)
  

Output of bazel version:

  
❯ 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:

  
http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"],
)

load(
    "@io_bazel_rules_docker//repositories:repositories.bzl",
    container_repositories = "repositories",
)

container_repositories()

load(
    "@io_bazel_rules_docker//go:image.bzl",
    _go_image_repos = "repositories",
)

_go_image_repos()



  

Anything else relevant?

clohr-vc avatar Jun 29 '22 17:06 clohr-vc

I am also facing this issue

mattstruble avatar Jul 21 '22 03:07 mattstruble

We ultimately decided to go ahead without bazel for now. The ability to deploy only what really needs redeploying from a golang monorepo is only viable using rules_docker, we're hoping to come back and re-evaluate this more in the future.

clohr-vc avatar Jul 21 '22 13:07 clohr-vc

Currently there is puller binary available for darwin/arm64. There is an open PR to add support: https://github.com/bazelbuild/rules_docker/pull/2033

uroshercog avatar Jul 25 '22 21:07 uroshercog

Facing this issue as well. Is there a workaround while the PR is still open?

pramodka-revefi avatar Aug 01 '22 19:08 pramodka-revefi

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 Jan 29 '23 02:01 github-actions[bot]

Not stale.

jfirebaugh avatar Jan 30 '23 16:01 jfirebaugh

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 Jul 31 '23 02:07 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 Aug 31 '23 02:08 github-actions[bot]