Closed
Description
What version of protobuf and what language are you using?
Version: 3.6.1
Language: Ruby
What operating system (Linux, Windows, ...) and version?
MacOS 10.14
What runtime / compiler are you using (e.g., python version or gcc version)
Ruby 2.4.1
What did you do?
Steps to reproduce the behavior:
- Compile the following proto:
protoc --proto_path=. --ruby_out=. example.proto
syntax = "proto3";
package google.example;
option java_multiple_files = true;
//option ruby_package = "Google::Example";
service HelloService {
rpc HiThere (HiRequest) returns (HiResponse);
}
message HiRequest {
string query = 1;
}
message HiResponse {
string result = 1;
}
- Repeat step 1 after uncommenting the
ruby_package
line.
What did you expect to see
The generated Ruby code should be the same.
What did you see instead?
When the ruby_package
options is specified the generated code is:
module Google::Example
HiRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.example.HiRequest").msgclass
HiResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.example.HiResponse").msgclass
end
Without the ruby_package
option it is:
module Google
module Example
HiRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.example.HiRequest").msgclass
HiResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.example.HiResponse").msgclass
end
end
This inconsistency causes issues because the module must already be defined if the ruby_package
option is used (example: googleapis/google-cloud-ruby#2782).
Anything else we should know about your project / environment
Activity
TeBoring commentedon Jan 22, 2019
Does the title of this issue correctly reflect the problem?
It seems to me the inconsistency is expected. The real issue is if the outer module is not defined. Is that correct?
jbolinger commentedon Jan 22, 2019
Why is the inconsistency expected?
The module not being defined is what can cause problems at runtime, but it's not clear to me why it should be different.