0

I'm working on a ruby application that has google protocol buffers.

My proto file :

syntax = 'proto3'

message QuestionMessage {
  int32 id = 1;
  string question = 2;
  int32 font_id = 3;
  repeated int32 answers = 4 [packed=true];
}

When I run protoc it does generate the correct ruby file, but :packed => true is missing for the repeated int32 named answers. The generated code:

add_message "QuestionMessage" do
  optional :id, :int32, 1
  optional :question, :string, 2
  optional :font_id, :int32, 3
  repeated :answers, :int32, 4
end

I currently think there is a problem with my protoc not generating the correct things for the ruby file. But the weird thing is that I have libprotoc version 3.1.0(Build from source) and the gemfile of the project also has version 3.1.0 and everything works (encode and making objects) except for generating :packed => true. Can somebody help me? I looked allover but couldn't even find someone with the same problems. B.t.w. adding :packet => true doesn't work because google does not like that.

Edit:
I found a solution. I used this gem to generate my ruby protoc files. These files I can edit instead off the files generated by the google-protobuf gem which you can't. Then I added :packed => true through a script. Not the best solution, but it is a solution..

  • It's possible the Ruby implementation does not support `packed`. (Just a guess; I don't actually know.) – Kenton Varda Oct 27 '16 at 02:48
  • @KentonVarda Sadly that's not it. If you look at [link](https://github.com/protobuf-ruby/beefcake) you can find files with `:packet => true`. I had found some documentation where it said you can write your own ruby files and not generate it from a proto file. But that is not desirable for my application because it has to communicate with other devices based on C code. Thanks for your comment btw. – Jelle Hoffman Oct 27 '16 at 11:10

0 Answers0