Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
They are in the process of migrating to Bazel, and so now there are build files in the repo. The migration isn't complete, so we want to force Gazelle to generate new build files as if it were a "normal" Go module. This doesn't seem to work as expected.
What did you expect to see?
Gazelle should generate clean build files, as if it were a normal Go module.
What did you see instead?
❯ bazel build //...
(14:30:02) INFO: Current date is 2023-02-01
(14:30:02) ERROR: /private/var/tmp/_bazel_thomas/d95eb470615df18f91feffc144a9a015/external/com_github_sourcegraph_sourcegraph/internal/extsvc/BUILD.bazel:3:11: error loading package '@com_github_sourcegraph_sourcegraph//schema': Unable to find package for @aspect_rules_js//js:defs.bzl: The repository '@aspect_rules_js' could not be resolved: Repository '@aspect_rules_js' is not defined. and referenced by '@com_github_sourcegraph_sourcegraph//internal/extsvc:extsvc'
(14:30:02) ERROR: Analysis of target '//<redacted>' failed; build aborted:
(14:30:02) INFO: Elapsed time: 0.913s
(14:30:02) INFO: 0 processes.
(14:30:02) FAILED: Build did NOT complete successfully (5 packages loaded, 0 targets configured)
currently loading: @com_github_sourcegraph_sourcegraph//schema
Fetching repository @io_opentelemetry_go_otel; starting
Fetching repository @com_github_gofrs_uuid; starting
Fetching repository @com_github_keegancsmith_sqlf; starting
Fetching repository @com_github_go_stack_stack; starting
What version of gazelle are you using?
v0.29.0
What version of rules_go are you using?
v0.38.1
What version of Bazel are you using?
6.0.0
Does this issue reproduce with the latest releases of all the above?
Yeah.
What operating system and processor architecture are you using?
macOS aarch64
What did you do?
We're building https://github.com/sourcegraph/sourcegraph with Bazel via the Go toolchain. The dependency is loaded through the
go_repository
rule:They are in the process of migrating to Bazel, and so now there are build files in the repo. The migration isn't complete, so we want to force Gazelle to generate new build files as if it were a "normal" Go module. This doesn't seem to work as expected.
What did you expect to see?
Gazelle should generate clean build files, as if it were a normal Go module.
What did you see instead?
Almost https://github.com/sourcegraph/sourcegraph/blob/ef114ac72b847cd6bca67a9adb9b2f32dc2cbcad/schema/BUILD.bazel, but not quite.
I would have expected Gazelle to wipe out the original build file first, but this doesn't seem to happen.