bazel-gazelle icon indicating copy to clipboard operation
bazel-gazelle copied to clipboard

Existence of go.mod file impacts generation of BUILD files depending on multi-module repositories

Open thompsonja opened this issue 3 years ago • 0 comments

What version of gazelle are you using?

0.24.0

What version of rules_go are you using?

0.29.0

What version of Bazel are you using?

4.2.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

gLinux / amd64

What did you do?

I have a working example at https://github.com/thompsonja/gazelle_example_multi_module_repo_error. The gist is that I have two separate workspaces with a package that depends on cloud.google.com/go/logging, which I have added as a go_repository named com_google_cloud_go_logging. The only difference between the two workspaces (asides from project prefix), is that one contains an empty go.mod file.

What did you expect to see?

I would expect that both invocations of gazelle should result in BUILD.bazel files with dependencies on @com_google_cloud_go_logging//:go_default_library

What did you see instead?

The result is that the workspace without the empty go.mod file gets this dependency added to the gazelle generated BUILD.bazel file:

deps = ["@com_google_cloud_go//logging:go_default_library"],

While the one with the empty go.mod file gets this one (the one I would expect):

deps = ["@com_google_cloud_go_logging//:go_default_library"],

thompsonja avatar Nov 04 '21 23:11 thompsonja