bazelbuild / rules_go

Go rules for Bazel
Apache License 2.0
1.35k stars 635 forks source link

rules_go + protobufs + experimental_sibling_repository_layout fails to build #3947

Open ted-xie opened 1 month ago

ted-xie commented 1 month ago

What version of rules_go are you using?

0.48. The issue also reproduces at commit 354a98f4acf2333b7603ede50dd5fbc20ae315b1.

What version of gazelle are you using?

N/A

What version of Bazel are you using?

7.1.2

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

Yes

What operating system and processor architecture are you using?

Debian-based Linux variant, x86_64 architecture.

Any other potentially useful information about your toolchain?

N/A

What did you do?

See repro at https://github.com/ted-xie/rules_go_proto_bug. TL;DR building a go_proto_library rule that's part of an external dependency with --experimental_sibling_repository_layout fails. Failure message:

Could not find file in descriptor database: ../maybe_rules_go_proto_bug~/proto/foo.proto: No such file or directory

What did you expect to see?

I expected the build to succeed.

What did you see instead?

The build fails due to the go proto compiler not being able to find the proto definition.

/cc @ahumesky

fmeum commented 1 month ago

I looked into this and the root cause is that:

This looks like a bug in ProtoInfo, probably in this line https://github.com/bazelbuild/bazel/blob/3a1b336ec8250547651f6c148f79ba1ced2448f2/src/main/starlark/builtins_bzl/common/proto/proto_info.bzl#L122

ahumesky commented 1 month ago

/cc @comius