You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module(
name = "demo",
version = "0.1.0",
)
bazel_dep(name = "rules_go", version = "0.49.0")
bazel_dep(name = "gazelle", version = "0.38.0")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.22.3")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(
go_work = "//:go.work",
)
use_repo(
go_deps,
"org_golang_x_example_hello",
)
In this demo, main.go imports example/hello/reverse by using go.work, and a new added function Int is called. This Int method is only existed in this local package. so if go.work works, building should success. if go.work doest work, then building should fail.
This demo works great by using go build, but fails by using bazel build //:demo. did anything I do wrong?
The demo project could be found in attachment: go-work.tar.gz
What did you expect to see?
building without any error.
What did you see instead?
ERROR: /Users/reficul/projects/go-work/BUILD.bazel:14:10: GoCompilePkg demo.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target //:demo) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_go~~go_sdk~demo__download_0/builder_reset/builder compilepkg -sdk external/rules_go~~go_sdk~demo__download_0 -goroot ... (remaining 29 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
main.go:10:47: undefined: reverse.Int
compilepkg: error running subcommand external/rules_go~~go_sdk~demo__download_0/pkg/tool/darwin_arm64/compile: exit status 2
Target //:demo failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.488s, Critical Path: 0.11s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully
The text was updated successfully, but these errors were encountered:
I haven't had much time for bazel stuff recently, but that might be changing. I'll attempt to carv out some time to investigate.
FWIW the go work demo was how I originally made this work, and I believe it inspired the tests within gazelle itself, so it is surprising to see a failure here.
What version of gazelle are you using?
0.38.0
What version of rules_go are you using?
0.49.0
What version of Bazel are you using?
7.2.1
Does this issue reproduce with the latest releases of all the above?
yes
What operating system and processor architecture are you using?
Darwin ReficuldeMBP.reficul.lab 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:34 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8103 arm64
What did you do?
I was following the official tutorial of go workspace with bzlmod. I created a demo project looks like below:
go.work looks like:
MODULE.bazel
looks like:In this demo,
main.go
importsexample/hello/reverse
by usinggo.work
, and a new added functionInt
is called. ThisInt
method is only existed in this local package. so ifgo.work
works, building should success. ifgo.work
doest work, then building should fail.This demo works great by using
go build
, but fails by usingbazel build //:demo
. did anything I do wrong?The demo project could be found in attachment: go-work.tar.gz
What did you expect to see?
building without any error.
What did you see instead?
The text was updated successfully, but these errors were encountered: