ruby-protobuf / protobuf

A pure ruby implementation of Google's Protocol Buffers
https://github.com/ruby-protobuf
MIT License
463 stars 101 forks source link

warning: already initialized constant Google::Protobuf::FileDescriptorSet #425

Closed ykitamura-mdsol closed 3 years ago

ykitamura-mdsol commented 3 years ago

When using with the latest version of google-protobuf 3.18.0, the gem starts producing these warnings:

../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:9: warning: already initialized constant Google::Protobuf::FileDescriptorSet
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:15: warning: previous definition of FileDescriptorSet was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:10: warning: already initialized constant Google::Protobuf::FileDescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:16: warning: previous definition of FileDescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:11: warning: already initialized constant Google::Protobuf::DescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:17: warning: previous definition of DescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:15: warning: already initialized constant Google::Protobuf::FieldDescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:23: warning: previous definition of FieldDescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:18: warning: already initialized constant Google::Protobuf::OneofDescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:53: warning: previous definition of OneofDescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:19: warning: already initialized constant Google::Protobuf::EnumDescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:54: warning: previous definition of EnumDescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:21: warning: already initialized constant Google::Protobuf::EnumValueDescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:55: warning: previous definition of EnumValueDescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:22: warning: already initialized constant Google::Protobuf::ServiceDescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:56: warning: previous definition of ServiceDescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:23: warning: already initialized constant Google::Protobuf::MethodDescriptorProto
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:57: warning: previous definition of MethodDescriptorProto was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:24: warning: already initialized constant Google::Protobuf::FileOptions
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:58: warning: previous definition of FileOptions was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:26: warning: already initialized constant Google::Protobuf::MessageOptions
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:67: warning: previous definition of MessageOptions was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:27: warning: already initialized constant Google::Protobuf::FieldOptions
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:68: warning: previous definition of FieldOptions was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:31: warning: already initialized constant Google::Protobuf::EnumOptions
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:83: warning: previous definition of EnumOptions was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:32: warning: already initialized constant Google::Protobuf::EnumValueOptions
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:84: warning: previous definition of EnumValueOptions was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:33: warning: already initialized constant Google::Protobuf::ServiceOptions
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:85: warning: previous definition of ServiceOptions was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:34: warning: already initialized constant Google::Protobuf::MethodOptions
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:86: warning: previous definition of MethodOptions was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:36: warning: already initialized constant Google::Protobuf::UninterpretedOption
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:87: warning: previous definition of UninterpretedOption was here
../gems/google-protobuf-3.18.0-universal-darwin/lib/google/protobuf/descriptor_pb.rb:38: warning: already initialized constant Google::Protobuf::SourceCodeInfo
../gems/protobuf-cucumber-3.10.8/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb:92: warning: previous definition of SourceCodeInfo was here

Probably this PR is the cause: https://github.com/protocolbuffers/protobuf/pull/8850

I assume google/protobuf/descriptor.pb doesn't need to be required when using with google-protobuf >= 3.18.0:

https://github.com/ruby-protobuf/protobuf/blob/db85425bc8a8d2a60d8e4ab46360e6bcd9074e28/lib/protobuf/descriptors.rb#L2

film42 commented 3 years ago

Thanks for opening an issue. I think you're using google's ruby protobuf lib. Please open an issue here: https://github.com/protocolbuffers/protobuf