bazel-gazelle
bazel-gazelle copied to clipboard
warning: could not locate GOROOT used by rules_go
What version of gazelle are you using?
5.1.0
What version of rules_go are you using?
0.31.0
What version of Bazel are you using?
bazel 5.1.1
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
macOS x86_64
What did you do?
tools/bazel_deps.bzl
# https://github.com/bazelbuild/buildtools/tree/master/buildifier#setup-and-usage-via-bazel-not-supported-on-windows
def fetch_buildifier_dependencies():
# buildifier is written in Go and hence needs rules_go to be built.
#
# Setup instructions:
# - https://github.com/bazelbuild/rules_go#initial-project-setup
#
# Latest releases:
# - https://github.com/bazelbuild/rules_go/releases
http_archive(
name = "io_bazel_rules_go",
sha256 = "f2dcd210c7095febe54b804bb1cd3a58fe8435a909db2ec04e31542631cf715c",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
],
)
# Setup instructions:
# - https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
#
# Latest releases:
# - https://github.com/bazelbuild/bazel-gazelle/releases
http_archive(
name = "bazel_gazelle",
sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
],
)
# Setup instructions:
# - https://github.com/bazelbuild/rules_go#protobuf-and-grpc
#
# Latest releases:
# - https://github.com/protocolbuffers/protobuf/releases
http_archive(
name = "com_google_protobuf",
sha256 = "8b28fdd45bab62d15db232ec404248901842e5340299a57765e48abe8a80d930",
strip_prefix = "protobuf-3.20.1",
urls = [
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.20.1.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v3.20.1.tar.gz",
],
)
# Setup instructions:
# - https://github.com/bazelbuild/buildtools/tree/master/buildifier#setup-and-usage-via-bazel-not-supported-on-windows
#
# Latest releases:
# - https://github.com/bazelbuild/buildtools/releases
http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "e3bb0dc8b0274ea1aca75f1f8c0c835adbe589708ea89bf698069d0790701ea3",
strip_prefix = "buildtools-5.1.0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/buildtools/archive/5.1.0.tar.gz",
"https://github.com/bazelbuild/buildtools/archive/5.1.0.tar.gz",
],
)
WORKSPACE
# Golang toolchain setup
# See https://github.com/bazelbuild/rules_go#initial-project-setup
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.18")
load("@io_bazel_rules_go//extras:embed_data_deps.bzl", "go_embed_data_dependencies")
go_embed_data_dependencies()
# Gazelle setup
# https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
# go_repository added due to: https://github.com/bazelbuild/bazel-gazelle/issues/1217
go_repository(
name = "org_golang_x_xerrors",
importpath = "golang.org/x/xerrors",
sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=",
version = "v0.0.0-20200804184101-5ec99f83aff1",
)
gazelle_dependencies()
# Protobuf setup
# See https://github.com/bazelbuild/rules_go#protobuf-and-grpc
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
BUILD.bazel
load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:prefix github.com/hyperbola
gazelle(
name = "gazelle",
)
gazelle(
name = "gazelle-update-repos",
args = [
"-from_file=tools/serce/go.mod",
"-to_macro=tools/serve/deps.bzl%go_dependencies",
"-prune",
],
command = "update-repos",
)
What did you expect to see?
Successful runs with no errors.
What did you see instead?
$ bazel run //:gazelle
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:gazelle up-to-date:
bazel-bin/gazelle-runner.bash
bazel-bin/gazelle
INFO: Elapsed time: 0.706s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
grep: MANIFEST: No such file or directory
/private/var/tmp/_bazel_lopopolo/266c5f221f27131e9994c6529de105d3/execroot/hyperbola_static/bazel-out/darwin-fastbuild/bin/gazelle: warning: could not locate GOROOT used by rules_go
$ bazel run //:gazelle-update-repos
INFO: Analyzed target //:gazelle-update-repos (0 packages loaded, 2 targets configured).
INFO: Found 1 target...
Target //:gazelle-update-repos up-to-date:
bazel-bin/gazelle-update-repos-runner.bash
bazel-bin/gazelle-update-repos
INFO: Elapsed time: 0.694s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
grep: MANIFEST: No such file or directory
/private/var/tmp/_bazel_lopopolo/266c5f221f27131e9994c6529de105d3/execroot/hyperbola_static/bazel-out/darwin-fastbuild/bin/gazelle-update-repos: warning: could not locate GOROOT used by rules_go
gazelle: running 'go go list -mod=readonly -e -m -json all': exec: "go": executable file not found in $PATH
Duplicate of #1009, fixed in #1247.