{"action":"closed","issue":{"url":"https://api.github.com/repos/bazelbuild/rules_go/issues/23","repository_url":"https://api.github.com/repos/bazelbuild/rules_go","labels_url":"https://api.github.com/repos/bazelbuild/rules_go/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/rules_go/issues/23/comments","events_url":"https://api.github.com/repos/bazelbuild/rules_go/issues/23/events","html_url":"https://github.com/bazelbuild/rules_go/issues/23","id":154850339,"number":23,"title":"cgo_library build fails with `/bin/bash: line 0: cd: HOME not set`","user":{"login":"jdanekrh","id":17877663,"avatar_url":"https://avatars.githubusercontent.com/u/17877663?v=3","gravatar_id":"","url":"https://api.github.com/users/jdanekrh","html_url":"https://github.com/jdanekrh","followers_url":"https://api.github.com/users/jdanekrh/followers","following_url":"https://api.github.com/users/jdanekrh/following{/other_user}","gists_url":"https://api.github.com/users/jdanekrh/gists{/gist_id}","starred_url":"https://api.github.com/users/jdanekrh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdanekrh/subscriptions","organizations_url":"https://api.github.com/users/jdanekrh/orgs","repos_url":"https://api.github.com/users/jdanekrh/repos","events_url":"https://api.github.com/users/jdanekrh/events{/privacy}","received_events_url":"https://api.github.com/users/jdanekrh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-14T12:09:48Z","updated_at":"2016-05-25T08:18:41Z","closed_at":"2016-05-25T08:18:41Z","body":"Building the following cgo project fails with `/bin/bash: line 0: cd: HOME not set`\r\n\r\n---\r\n\r\n    $ ls\r\n    bazel-bin  bazel-cgotest  bazel-genfiles  bazel-out  bazel-testlogs  BUILD  cgo.go  WORKSPACE\r\n\r\n---\r\n    cat BUILD \r\n    load(\"@io_bazel_rules_go//go:def.bzl\", \"go_prefix\", \"cgo_library\")\r\n    \r\n    go_prefix(\"cgotest\")\r\n    \r\n    cgo_library(\r\n        name = \"cgo\",\r\n        srcs = [\"cgo.go\"],\r\n    )\r\n\r\n---\r\n\r\n    $ cat WORKSPACE \r\n    git_repository(\r\n        name = \"io_bazel_rules_go\",\r\n        remote = \"https://github.com/bazelbuild/rules_go.git\",\r\n        tag = \"0.0.2\",\r\n    )\r\n    load(\"@io_bazel_rules_go//go:def.bzl\", \"go_repositories\")\r\n    go_repositories()\r\n\r\nThe build itself\r\n\r\n    $ ~/bin/bazel build //:cgo --verbose_failures\r\n    WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.io/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.\r\n    INFO: Found 1 target...\r\n    ERROR: /vagrant/cgotest/BUILD:5:1: error executing shell command: 'export GOROOT=$(pwd)/external/golang_linux_amd64/go/bin/.. && export CC=$(cd $(dirname /usr/bin/gcc); pwd)/$(basename /usr/bin/gcc) && export CXX=$CC && objdir=$(pwd)/bazel-out/local-fastbuild/genf...' failed: bash failed: error executing command \r\n    (cd /home/vagrant/.cache/bazel/_bazel_vagrant/b4ea8fffb29363907600583bb5450a23/cgotest && \\\r\n    exec env - \\\r\n        CGO_LDFLAGS='' \\\r\n        GOARCH=amd64 \\\r\n        GOOS=linux \\\r\n    /bin/bash -c 'export GOROOT=$(pwd)/external/golang_linux_amd64/go/bin/.. && export CC=$(cd $(dirname /usr/bin/gcc); pwd)/$(basename /usr/bin/gcc) && export CXX=$CC && objdir=$(pwd)/bazel-out/local-fastbuild/genfiles/cgo.cgo.dir && mkdir -p $objdir && cd  && $GOROOT/bin/go tool cgo -objdir $objdir -- cgo.go && rm -f $objdir/_cgo_.o $objdir/_cgo_flags'): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.\r\n    /bin/bash: line 0: cd: HOME not set\r\n    Target //:cgo failed to build\r\n    INFO: Elapsed time: 0.463s, Critical Path: 0.08s\r\n\r\nI think the cause is that `ctx.label.package` on line https://github.com/bazelbuild/rules_go/blob/master/go/def.bzl#L522 is an empty string. I tried figuring out what is supposed to initialize that variable, but I could not in the time I was willing to spend on it.\r\n\r\nIf I change `cgo_library` to `go_library` and comment out all cgo parts from `cgo.go`, then compilation succeeds.\r\n\r\nI am using RHEL 7.2, OpenJDK 1.8 and current release of Bazel."}}
{"actor":{"display_login":"damienmg"}}