Rules_go: importpath_aliases not implemented for go_proto_library

Created on 3 Feb 2020  路  3Comments  路  Source: bazelbuild/rules_go

What version of rules_go are you using?

v0.21.2

What version of gazelle are you using?

v0.19.1

What version of Bazel are you using?

2.0.0

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

Yes

What operating system and processor architecture are you using?

Ubuntu amd64

Any other potentially useful information about your toolchain?

N/A

What did you do?

blaze run //:gazelle -- update-repos github.com/dgraph-io/badger/v2

(v2 isn't a real directory but an module named in: https://github.com/dgraph-io/badger/blob/master/go.mod)

What did you expect to see?

The result should build

What did you see instead?

$ blaze build :all
ERROR: /home/mike/.cache/bazel/_bazel_mike/00f1347297fd781be7971b81296fd31c/external/com_github_dgraph_io_badger_v2/pb/BUILD.bazel:10:1: @com_github_dgraph_io_badger_v2//pb:pb_go_proto: no such attribute 'importpath_aliases' in 'go_proto_library' rule
ERROR: /home/mike/.cache/bazel/_bazel_mike/00f1347297fd781be7971b81296fd31c/external/com_github_dgraph_io_badger_v2/pb/BUILD.bazel:4:1: Target '@com_github_dgraph_io_badger_v2//pb:pb.proto' contains an error and its package is in error and referenced by '@com_github_dgraph_io_badger_v2//pb:pb_proto'
ERROR: /home/mike/.cache/bazel/_bazel_mike/00f1347297fd781be7971b81296fd31c/external/com_github_dgraph_io_badger_v2/pb/BUILD.bazel:10:1: Target '@com_github_dgraph_io_badger_v2//pb:pb_proto' contains an error and its package is in error and referenced by '@com_github_dgraph_io_badger_v2//pb:pb_go_proto'
ERROR: /home/mike/.cache/bazel/_bazel_mike/00f1347297fd781be7971b81296fd31c/external/com_github_dgraph_io_badger_v2/pb/BUILD.bazel:18:1: Target '@com_github_dgraph_io_badger_v2//pb:pb_go_proto' contains an error and its package is in error and referenced by '@com_github_dgraph_io_badger_v2//pb:go_default_library'
ERROR: /home/mike/.cache/bazel/_bazel_mike/00f1347297fd781be7971b81296fd31c/external/com_github_dgraph_io_badger_v2/BUILD.bazel:3:1: Target '@com_github_dgraph_io_badger_v2//pb:go_default_library' contains an error and its package is in error and referenced by '@com_github_dgraph_io_badger_v2//:go_default_library'
ERROR: Analysis of target '//collecty:go_default_library' failed; build aborted: Analysis failed
INFO: Elapsed time: 1.602s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (3 packages loaded, 203 targets configured)


I see importpath_aliases is defined for go_library, but not go_proto_library? However gazelle generates BUILD files that use them:

go_proto_library(
name = "pb_go_proto",
importpath = "github.com/dgraph-io/badger/v2/pb",
importpath_aliases = ["github.com/dgraph-io/badger/pb"],
proto = ":pb_proto",
visibility = ["//visibility:public"],
)

bug proto

Most helpful comment

go_proto_library ought to have this attribute, so this is a bug.

If you don't need the .pb.go files to be generated at build time, and you can use pre-generated proto files instead, you may be able to work around this by setting build_file_proto_mode = "disable" on the go_repository rule. Or "disable_global" on all go_repository rules with protos.

All 3 comments

go_proto_library ought to have this attribute, so this is a bug.

If you don't need the .pb.go files to be generated at build time, and you can use pre-generated proto files instead, you may be able to work around this by setting build_file_proto_mode = "disable" on the go_repository rule. Or "disable_global" on all go_repository rules with protos.

Thanks Jay, I rolled back to an earlier version of the library that didn't use the aliasing stuff. That works for me for now. Thank's for the prompt analysis.

@jayconrod Could you give me some guidance on how this should be fixed, I would like to the go_proto_library rules generated by gazelle.

Was this page helpful?
0 / 5 - 0 ratings