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

rules_go bumps the version of google.golang.org/genproto required by root module #3802

Closed
linzhp opened this issue Dec 27, 2023 · 0 comments · Fixed by #3803
Closed

rules_go bumps the version of google.golang.org/genproto required by root module #3802

linzhp opened this issue Dec 27, 2023 · 0 comments · Fixed by #3803

Comments

@linzhp
Copy link
Contributor

linzhp commented Dec 27, 2023

What version of rules_go are you using?

0.44.0

What version of gazelle are you using?

0.35.0

What version of Bazel are you using?

7.0.0

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

Yes

What operating system and processor architecture are you using?

Linux arm64

What did you do?

Run bazel build @com_github_pseudomuto_protoc_gen_doc//cmd/protoc-gen-doc in the following workspace:

-- go.mod --
module example.com/go

go 1.19

require github.com/pseudomuto/protoc-gen-doc v1.5.1

require (
        github.com/Masterminds/semver v1.4.2 // indirect
        github.com/Masterminds/sprig v2.15.0+incompatible // indirect
        github.com/aokoli/goutils v1.0.1 // indirect
        github.com/envoyproxy/protoc-gen-validate v0.3.0-java // indirect
        github.com/gogo/protobuf v1.1.1 // indirect
        github.com/golang/protobuf v1.5.3 // indirect
        github.com/google/go-cmp v0.5.6 // indirect
        github.com/google/uuid v1.1.2 // indirect
        github.com/huandu/xstrings v1.0.0 // indirect
        github.com/imdario/mergo v0.3.4 // indirect
        github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007 // indirect
        github.com/pseudomuto/protokit v0.2.0 // indirect
        golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
        google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
        google.golang.org/protobuf v1.30.0 // indirect
)
-- MODULE.bazel --
module(name = "example")

###########################################
############ Bazel modules ################
###########################################
bazel_dep(name = "rules_go", version = "0.44.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.35.0", repo_name = "bazel_gazelle")

###########################################
########### Toolchain Registrations #######
###########################################
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
    name = "go_sdk",
    version = "1.21.5",
)
use_repo(go_sdk, "go_sdk")

###########################################
############# Third-party DEPENDENCIES ####
###########################################
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
    go_deps,
    "com_github_pseudomuto_protoc_gen_doc",
)
-- tools.go --
//go:build tools
// +build tools

package main

// Before adding a dependency visit: t.uber.com/tool-dependencies
import (
        _ "github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
)

What did you expect to see?

Build completes successfully

What did you see instead?

ERROR: no such package '@@gazelle~0.35.0~go_deps~org_golang_google_genproto//googleapis/api/annotations': BUILD file not found in directory 'googleapis/api/annotations' of external repository @@gazelle~0.35.0~go_deps~org_golang_google_genproto. Add a BUILD file to a directory to mark it as a package.
ERROR: /home/user/.cache/bazel/_bazel_zplin/99f39cef3324947e0938218b2f5ab9e8/external/gazelle~0.35.0~go_deps~com_github_pseudomuto_protoc_gen_doc/extensions/google_api_http/BUILD.bazel:3:11: no such package '@@gazelle~0.35.0~go_deps~org_golang_google_genproto//googleapis/api/annotations': BUILD file not found in directory 'googleapis/api/annotations' of external repository @@gazelle~0.35.0~go_deps~org_golang_google_genproto. Add a BUILD file to a directory to mark it as a package. and referenced by '@@gazelle~0.35.0~go_deps~com_github_pseudomuto_protoc_gen_doc//extensions/google_api_http:google_api_http'
ERROR: Analysis of target '@@gazelle~0.35.0~go_deps~com_github_pseudomuto_protoc_gen_doc//cmd/protoc-gen-doc:protoc-gen-doc' failed; build aborted: Analysis failed
INFO: Elapsed time: 1.741s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

Notes

Despite github.com/pseudomuto/protoc-gen-doc requires google.golang.org/genproto@v0.0.0-20210917145530-b395a37504d4, rules_go bumps it to a much newer version:

google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4

The new version separates google.golang.org/genproto/googleapis/api into a separate module, and google.golang.org/genproto@v0.0.0-20231127180814-3a041ad873d4 no longer has the package googleapis/api/annotations. Because the root module doesn't import any Go code transitively from rules_go, the root go.mod file is unaware of the go.mod file from rules_go and the new version of google.golang.org/genproto it introduces.

The particular issue can be worked around by replacing with google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect with
google.golang.org/genproto/googleapis/api v0.0.0-20230525153121-6704ef2c6e07 // indirect in the root go.mod file, but we should keep the version of google.golang.org/genproto low to prevent future users running into such issue.

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

Successfully merging a pull request may close this issue.

1 participant