Skip to content

fix: support aggregator proto_library deps and put generated code on the load path - #424

Open
pwhite-mongo wants to merge 1 commit into
bazel-contrib:mainfrom
pwhite-mongo:fix/proto-aggregators-and-load-paths
Open

pwhite-mongo wants to merge 1 commit into
bazel-contrib:mainfrom
pwhite-mongo:fix/proto-aggregators-and-load-paths

Conversation

@pwhite-mongo

Copy link
Copy Markdown

disclaimer: This is robot code. I experienced the problem described below, fidgeted with settings I didn't understand for a couple hours, and then finally found the issue. Being only marginally useful with either bazel or ruby, I caved to pressure and told claude chase down the error I get from bazel build :blahblah. I have checked it myself, for whatever that's worth, and am willing to stake my reputation on the output. Claude's message is below:

The Ruby proto aspect indexed the first generated file unconditionally, so analysis failed on proto_library targets that only bundle other protos via deps (e.g. @envoy_api//:v3_protos):

Error: index out of range (index is 0, but sequence has 0 elements)

Such targets now generate nothing and forward their deps' Ruby files.

Generated _pb.rb files require each other relative to their proto import root, but only the runfiles root was on RUBYLIB, so protos from external repositories (and stripped/virtual import prefixes) could not be required. RubyFilesInfo gains transitive_load_paths, which the aspect populates with each output root and rb_binary/rb_test prepend to RUBYLIB. This removes the need for the manual $LOAD_PATH setup in examples/proto.

Protos from @protobuf are skipped so the well-known types come from the google-protobuf gem rather than generated copies shadowing it.

The proto example CI job now runs tests instead of only building the app.

@pwhite-mongo
pwhite-mongo force-pushed the fix/proto-aggregators-and-load-paths branch from a8ddba8 to f2a89a6 Compare October 14, 2026 18:18
…the load path

The Ruby proto aspect indexed the first generated file unconditionally, so
analysis failed on proto_library targets that only bundle other protos via
`deps` (e.g. `@envoy_api//:v3_protos`):

    Error: index out of range (index is 0, but sequence has 0 elements)

Such targets now generate nothing and forward their deps' Ruby files.

Generated `_pb.rb` files require each other relative to their proto import
root, but only the runfiles root was on RUBYLIB, so protos from external
repositories (and stripped/virtual import prefixes) could not be required.
RubyFilesInfo gains `transitive_load_paths`, which the aspect populates with
each output root and rb_binary/rb_test prepend to RUBYLIB. This removes the
need for the manual $LOAD_PATH setup in examples/proto.

Protos from @protobuf are skipped so the well-known types come from the
google-protobuf gem rather than generated copies shadowing it.

The proto example CI job now runs tests instead of only building the app.
@pwhite-mongo
pwhite-mongo force-pushed the fix/proto-aggregators-and-load-paths branch from f2a89a6 to 8fda41b Compare October 14, 2026 18:24
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 this pull request may close these issues.

1 participant