Protobuf: google-protobuf gem 3.1.0 is not compatible with Ruby 2.4

Created on 26 Dec 2016  路  6Comments  路  Source: protocolbuffers/protobuf

The reason appears to be because google-protobuf currently uses rb_cFixnum, which is not supported in Ruby 2.4 because the Fixnum/Bignum distinction has been removed. I haven't dug into where this is in the code, but this effectively prevents all gRPC-based google API clients from working on Ruby 2.4, so it needs to be addressed asap.

Repro:

% ruby --version
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
% gem install google-protobuf
Fetching: google-protobuf-3.1.0-x86_64-linux.gem (100%)
Successfully installed google-protobuf-3.1.0-x86_64-linux
Parsing documentation for google-protobuf-3.1.0-x86_64-linux
Installing ri documentation for google-protobuf-3.1.0-x86_64-linux
Done installing documentation for google-protobuf after 0 seconds
1 gem installed
% irb
irb(main):001:0> gem "google-protobuf"
=> true
irb(main):002:0> require "google/protobuf"
LoadError: /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-protobuf-3.1.0-x86_64-linux/lib/google/protobuf_c.so: undefined symbol: rb_cFixnum - /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-protobuf-3.1.0-x86_64-linux/lib/google/protobuf_c.so
        from /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-protobuf-3.1.0-x86_64-linux/lib/google/protobuf.rb:50:in `rescue in <top (required)>'
        from /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-protobuf-3.1.0-x86_64-linux/lib/google/protobuf.rb:47:in `<top (required)>'
        from /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from (irb):2
        from /usr/local/google/home/dazuma/.rbenv/versions/2.4.0/bin/irb:11:in `<main>'
irb(main):003:0>

Most helpful comment

@palkan Sorry for the delay! We're resolving some build issues internally with the gems, but it should be any day now.

All 6 comments

I believe all that needs to be done is to rebuild the gem using the Ruby 2.4 headers.

AFAICT, the current code appears to reference the Fixnum class only via pre-2.4 header macros. I also tried building the native gem against the 2.4 ruby.h, and it runs correctly on Ruby 2.4 (as well as being backward compatible with 2.3.3); whereas when I go back and rebuild the native gem against the 2.3.3 ruby.h, that fails on Ruby 2.4.

Thanks for the report! In our next release we will be sure to include a binary gem for 2.4.

@TeBoring

Looks like 3.2.0 has been released but haven't been pushed to RubyGems. Any news on when it will be published?

@palkan Sorry for the delay! We're resolving some build issues internally with the gems, but it should be any day now.

Was this page helpful?
0 / 5 - 0 ratings