bazel-contrib / bazel-contrib/rules_go
Conflicting WKT descriptors from com_github_golang_protobuf and io_bazel_rules_go
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 760
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
### What version of rules_go are you using?
v0.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?
macOS Big Sur, x86_64
### Any other potentially useful information about your toolchain?
N/A
### What did you do?
Invoke the [prototool](https://github.com/uber/prototool) binary from the command line.
```
$ bazel run @com_uber_prototool//cmd/prototool -- version
```
### What did you expect to see?
Prototool to run and stdout it's current version.
### What did you see instead?
Conflicting golang protobuf descriptors. Note that [@com_uber_prototool//bazel:deps.bzl](https://github.com/uber/prototool/blob/a6d064684c011c8482f4218c681a66a64031fb1d/bazel/deps.bzl#L70) imports `com_github_golang_protobuf`.
```shell
INFO: Analyzed target @com_uber_prototool//cmd/prototool:prototool (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_user/f680ea5836cbaf558e75ca93509d30ef/external/com_uber_prototool/cmd/prototool/BUILD.bazel:11:10: GoLink external/com_uber_prototool/cmd/prototool/prototool_/prototool failed: (Exit 1): builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder link -sdk external/go_sdk -installsuffix darwin_amd64 -arc ... (remaining 329 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
link: package conflict error: github.com/golang/protobuf/protoc-gen-go/descriptor: multiple copies of package passed to linker:
@com_github_golang_protobuf//protoc-gen-go/descriptor:descriptor
@io_bazel_rules_go//proto/wkt:descriptor_go_proto
Set "importmap" to different paths or use 'bazel cquery' to ensure only one
package with this path is linked.
Target @com_uber_prototool//cmd/prototool:prototool failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.440s, Critical Path: 0.14s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
```
### What's your WORKSPACE?
```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
urls = [
"https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.17.2")
http_archive(
name = "bazel_gazelle",
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
urls = [
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
],
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
gazelle_dependencies()
http_archive(
name = "com_google_protobuf",
sha256 = "87407cd28e7a9c95d9f61a098a53cf031109d451a7763e7dd1253abf8b4df422",
strip_prefix = "protobuf-3.19.1",
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz",
],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
go_repository(
name = "com_uber_prototool",
build_file_proto_mode = "disable",
commit = "a6d064684c011c8482f4218c681a66a64031fb1d",
importpath = "github.com/uber/prototool",
)
load("@com_uber_prototool//bazel:deps.bzl", "prototool_deps")
prototool_deps()
```
Contributor guide
Research direction
Start with the WORKSPACE dependency declarations and @com_uber_prototool//bazel:deps.bzl, then reproduce the failure with `bazel run @com_uber_prototool//cmd/prototool -- version`. Compare the com_github_golang_protobuf descriptor with @io_bazel_rules_go//proto/wkt:descriptor_go_proto; done means the target builds without the package conflict and prints its version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100