bazel-contrib / bazel-contrib/rules_go

rules_go pulling Envoy proxy protoc and breaking builds

Open
#4,409 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### rules_go version
0.54.1

### gazelle version
0.43.0

### bazel version
```
$ bazel version
Bazelisk version: v1.23.0
Build label: 8.3.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Jun 30 16:23:40 2025 (1751300620)
Build timestamp: 1751300620
Build timestamp as int: 1751300620
```

### Build platform
Linux, x86_64

---

I'm trying to add a GCS Go API dependency to my project [g2disk](https://github.com/popovicu/g2disk). This is done in popovicu/g2disk@5c081a7236d54e76b8a2713f07ac05d314ac3fa3

As a test, I simply want to build the GCS library:

```
bazel build //remote/gcs
```

However, the build fails because Go rules + Gazelle bring in some strange Envoy proxy dependencies, not sure why would they even be included:

```
$ bazel build //remote/gcs
ERROR: error loading package '@@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate//validate': Unable to find package for @@[unknown repo 'rules_python' requested from @@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate (did you mean 'rules_proto'?)]//python:proto.bzl: The repository '@@[unknown repo 'rules_python' requested from @@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate (did you mean 'rules_proto'?)]' could not be resolved: No repository visible as '@rules_python' from repository '@@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate'.
ERROR: /home/uros/.cache/bazel/_bazel_uros/62b3f0231c97c4b58fda1fd00c41b8ac/external/gazelle++go_deps+com_github_cncf_xds_go/xds/type/v3/BUILD.bazel:3:11: error loading package '@@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate//validate': Unable to find package for @@[unknown repo 'rules_python' requested from @@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate (did you mean 'rules_proto'?)]//python:proto.bzl: The repository '@@[unknown repo 'rules_python' requested from @@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate (did you mean 'rules_proto'?)]' could not be resolved: No repository visible as '@rules_python' from repository '@@gazelle++go_deps+com_github_envoyproxy_protoc_gen_validate'. and referenced by '@@gazelle++go_deps+com_github_cncf_xds_go//xds/type/v3:type'
ERROR: Analysis of target '//remote/gcs:gcs' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.389s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED:
Fetching repository @@gazelle++go_deps+io_opentelemetry_go_otel; starting
Fetching repository @@gazelle++go_deps+org_golang_google_genproto; starting
Fetching repository @@gazelle++go_deps+org_golang_google_api; starting
Fetching repository @@gazelle++go_deps+org_golang_x_net; starting
Fetching repository @@gazelle++go_deps+com_github_envoyproxy_go_control_plane_envoy; starting
```

My `//remote/gcs` target is an alias for `@com_google_cloud_go_storage//:go_default_library`.

This remote dependency was added to the project with this:

```
bazel run @rules_go//go -- get cloud.google.com/go/storage@latest
```

I've tried adding `rules_python` and `rules_java` to the `MODULE.bazel` file, but the error persisted.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `bazel build //remote/gcs` in the linked g2disk setup and inspect the MODULE.bazel dependency declarations. Trace why Gazelle and rules_go bring in `com_github_envoyproxy_protoc_gen_validate` and why its `rules_python` repository is not visible. Done means the GCS target builds without the unresolved repository error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.