Open tyler-french opened 1 month ago
In Bazel 7.4.0 and 8, you will be able to have go_deps
reuse the bazel_dep
via override_repo
. I will add a test case to verify that bazel mod tidy
behaves correctly in that case.
I wonder if for now we can just look at all the repo_name
of the bazel_dep
in the root MODULE.bazel, and then skip adding these to direct dependencies?
The Gazelle extension can't do this as it doesn't have access to MODULE files.
Having looked into this more, I think that it's actually a feature (but not with a good error message): You have the same dep show up under two different names in your dep tree, which can result in linker errors. Instead, when Bazel 7.4.0 lands, you should use override_repo
to replace the extension repo with the Bazel dep.
I am facing a similar problem, but the project I am working on uses Bazel 7.0.2
, and this is something I don't have control over.
Is there a way to manually tell Gazelle not to manage a specific dependency in older Bazel versions that don't have override_repo
?
Could you rename the conflicting dep via the repo_name
attribute of bazel_dep
? We can add a new knob, I would just like to make sure it's the right one and actually needed.
This is the solution I ended up going with, but it's not ideal because I am virtually importing the same dependency twice.
bazel_dep("grpc_gateway", version = "2.23.0") # removed `, repo_name = "com_github_grpc_ecosystem_grpc_gateway_v2"`
use_repo(
go_deps,
"com_github_grpc_ecosystem_grpc_gateway_v2", # added via go.mod
)
To reproduce:
MODULE.bazel
go.mod (includes direct dep)
bazel mod tidy
:Build failure caused: