Rules_docker: In Mac, standard_init_linux.go:195: exec user process caused "exec format error"

Created on 22 Mar 2018  路  1Comment  路  Source: bazelbuild/rules_docker

I got following error, when I was running following command on Mac.

$ bazel run //:go_image
INFO: Analysed target //:go_image (23 packages loaded).
INFO: Found 1 target...
Target //:go_image up-to-date:
  bazel-bin/go_image-layer.tar
INFO: Elapsed time: 11.514s, Critical Path: 11.10s
INFO: Build completed successfully, 27 total actions

INFO: Running command line: bazel-bin/go_image
Loaded image ID: sha256:25fabb67d3eea0c4bd5137090d621fafa9d07e6cfd0d87e28c5366ddcf4e9e8d
Tagging 25fabb67d3eea0c4bd5137090d621fafa9d07e6cfd0d87e28c5366ddcf4e9e8d as bazel:go_image
standard_init_linux.go:195: exec user process caused "exec format error"
ERROR: Non-zero return code '1' from command: Process exited with status 1

Files

main.go

package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
}

WORKSPACE

git_repository(
    name = "io_bazel_rules_go",
    remote = "https://github.com/bazelbuild/rules_go.git",
    tag = "0.10.1",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains", "go_repository")
go_rules_dependencies()
go_register_toolchains()

git_repository(
    name = "io_bazel_rules_docker",
    remote = "https://github.com/bazelbuild/rules_docker.git",
    tag = "v0.4.0",
)
load(
    "@io_bazel_rules_docker//container:container.bzl",
    "container_pull",
    container_repositories = "repositories",
)
container_repositories()
load(
    "@io_bazel_rules_docker//go:image.bzl",
    _go_image_repos = "repositories",
)
_go_image_repos()

BUILD

load("@io_bazel_rules_docker//go:image.bzl", "go_image")

go_image(
    name = "go_image",
    srcs = ["main.go"],
    pure = "on",
)

Most helpful comment

The go_binary isn't cross-compiling, so it's trying to run an OSX binary in a linux container.

What you want is this flag, which you can put into a .bazelrc in the root of your repo:

run --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64

>All comments

The go_binary isn't cross-compiling, so it's trying to run an OSX binary in a linux container.

What you want is this flag, which you can put into a .bazelrc in the root of your repo:

run --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64
Was this page helpful?
0 / 5 - 0 ratings

Related issues

UebelAndre picture UebelAndre  路  5Comments

salrashid123 picture salrashid123  路  8Comments

fishy picture fishy  路  4Comments

gorset picture gorset  路  3Comments

v48 picture v48  路  8Comments