bazel-gazelle
bazel-gazelle copied to clipboard
BUILD file not generated when using go_repository
What version of gazelle are you using?
v.0.24.0
What version of rules_go are you using?
v0.28.0
What version of Bazel are you using?
4.2.0
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
Mac OS/ x86
What did you do?
Im attempting to download the following repository
go_repository(
name = "com_github_actgardner_gogen_avro_v10",
importpath = "github.com/actgardner/gogen-avro/v10",
sum = "h1:d48HiGDcH+p8BDUgSkV0mtwWTeIj96jF1X3lVbWI6Ng=",
version = "v10.1.0",
)
and my BUILD file looks like this
go_library(
name = "go_default_library",
srcs = ["main.go"],
deps = [
"@com_github_actgardner_gogen_avro_v10//:go_default_library",
],
importpath = "compass.com/bazel_example/cmd",
visibility = ["//visibility:private"],
)
What did you expect to see?
I'm expecting a BUILD.bazel file to be generated in the repository being downloaded.
What did you see instead?
When I attempt to build my target, I get the following error:
/Users/evan.arbeitman/development/urbancompass/build-support/bazel/bin/bazel-4.2.0 build //src/go/compass.com/bazel_example/cmd:go_default_library
ERROR: /Users/evan.arbeitman/development/urbancompass/src/go/compass.com/bazel_example/cmd/BUILD:3:11: no such package '@com_github_actgardner_gogen_avro_v10//': BUILD file not found in directory '' of external repository @com_github_actgardner_gogen_avro_v10. Add a BUILD file to a directory to mark it as a package. and referenced by '//src/go/compass.com/bazel_example/cmd:go_default_library'
ERROR: Analysis of target '//src/go/compass.com/bazel_example/cmd:go_default_library' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.729s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)
This is expected behavior. Gazelle doesn't generate a BUILD file under the directory you are trying to import (github.com/actgardner/gogen-avro/v10
) because it contains no go code to be imported.
I tested importing a package in that repo with go code (github.com/actgardner/gogen-avro/v10/generic
), and Gazelle properly generated BUILD files and I was able to build.