Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gazelle does not rewrite build files from vendored go code #1982

Closed
fishy opened this issue Nov 19, 2024 · 1 comment
Closed

gazelle does not rewrite build files from vendored go code #1982

fishy opened this issue Nov 19, 2024 · 1 comment

Comments

@fishy
Copy link

fishy commented Nov 19, 2024

What version of gazelle are you using?

0.40.0

What version of rules_go are you using?

0.50.1

What version of Bazel are you using?

7.4.1

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

Those are latest releases

What operating system and processor architecture are you using?

linux/amd64

What did you do?

As mitigation to #1977, we start to vendor via go mod vendor.

go mod vendor keeps build files from go dependencies if they exist. Some of our go dependencies (github.com/grpc-ecosystem/grpc-gateway & github.com/google/flatbuffers) have build files using io_bazel_rules_go. For example: https://github.com/grpc-ecosystem/grpc-gateway/blob/195cb0fb4abb13a20b42dc97dd754fc81e28b63d/utilities/BUILD.bazel#L1.

We use rules_go as the name in our MODULE.bazel:

...
bazel_dep(name = "rules_go", version = "0.50.1")
...

And after go mod vendor, bazel run //:gazelle -- fix also left those build files untouched (it generates build files for vendored directories lacking them, but not change them if they already exists), resulting in the code won't build because io_bazel_rules_go cannot be resolved.

Currently we just run buildozer after bazel run //:gazelle -- fix:

buildozer 'substitute_load ^@io_bazel_rules_go//(.*)$ @rules_go//${1}' //vendor/...:__pkg__

But it would be great if gazelle can (provide an option to) fix them so we don't have to use buildozer.

What did you expect to see?

What did you see instead?

@fishy
Copy link
Author

fishy commented Nov 19, 2024

I guess we can also do this between go mod vendor and bazel run //:gazelle --fix to force gazelle to regenerate all build files:

find vendor/ \( -name "BUILD" -o -name "BUILD.bazel" \) -delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant