Protobuf: Protobuf can't be required on Ruby 2.6

Created on 17 Sep 2018  Â·  14Comments  Â·  Source: protocolbuffers/protobuf

What version of protobuf and what language are you using?
Version: v3.6.1
Language: Ruby

What operating system (Linux, Windows, ...) and version?

[aaron@TC ~]$ uname -a
Darwin TC.local 17.7.0 Darwin Kernel Version 17.7.0: Fri Jul  6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64 x86_64

What runtime / compiler are you using (e.g., python version or gcc version)

[aaron@TC ~]$ ruby -v
ruby 2.6.0dev (2018-06-21 gc-compact-7-27 63710) [x86_64-darwin17]
last_commit=Yay!  We did more work!!!
[aaron@TC ~]$ 

What did you do?
Steps to reproduce the behavior:

  1. Install Ruby 2.6 from source
  2. Install google-protobuf gem
  3. Require protobuf
  4. See error when requiring the gem

What did you expect to see

The gem can be required

What did you see instead?

An error indicating the gem cannot be required. Here is the output on my terminal:

[aaron@TC ~]$ gem install google-protobuf
Successfully installed google-protobuf-3.6.1-universal-darwin
Parsing documentation for google-protobuf-3.6.1-universal-darwin
Done installing documentation for google-protobuf after 0 seconds
1 gem installed
[aaron@TC ~]$ ruby -r google/protobuf -e'puts "hello"'
Traceback (most recent call last):
    6: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
    5: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
    4: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
    3: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.6.0/gems/google-protobuf-3.6.1-universal-darwin/lib/google/protobuf.rb:47:in `<top (required)>'
    2: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.6.0/gems/google-protobuf-3.6.1-universal-darwin/lib/google/protobuf.rb:50:in `rescue in <top (required)>'
    1: from /Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- google/protobuf_c (LoadError)

Anything else we should know about your project / environment

I am working against a development version of Ruby.

Thanks!

P3 bug question ruby

Most helpful comment

Glancing at the diff, it doesn't seem tied to protobuf-3.7.0 (AFAICT); would be great to get this backported to a rubygem w/protobuf-3.6.x as currently it's blocking us moving to Ruby 2.6.

All 14 comments

I was able to get this to work by manually specifying the platform is ruby:

[aaron@TC ~]$ gem install google-protobuf --platform=ruby
Fetching: google-protobuf-3.6.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed google-protobuf-3.6.1
Parsing documentation for google-protobuf-3.6.1
Installing ri documentation for google-protobuf-3.6.1
Done installing documentation for google-protobuf after 3 seconds
1 gem installed
[aaron@TC ~]$ ruby -r google/protobuf -e'puts "hello"'
hello

I'm not sure if that's supported/expected, but it did get me unblocked. 😊

I was able to get this to work by manually specifying the platform is ruby

This is the workaround we have been given when a new version of Ruby is released. The pre-compiled gems usually show up ~February, so until then we either have to set the platform and compile the gems when installing, or use the previous Ruby version until the pre-compiled gems are available.

Although I can use ruby 2.6.0 to do rake test in ruby/ dir, I cannot pass ruby/compatibility_test/v3.0.0.
The error is that: File does not exist: google/protobuf

I tried to copy the lib dir generated by rake test in ruby dir.
It failed with: incompatible library version - /home/teboring/protobuf-ruby26-test2/ruby/compatibility_tests/v3.0.0/lib/google/protobuf_c.so

Fixed by #5537

Btw. do you plan to push rebuilt gems to rubygems.org as well?

Since this issue is part of v3.7.0, I'd guess it might take a while.

Glancing at the diff, it doesn't seem tied to protobuf-3.7.0 (AFAICT); would be great to get this backported to a rubygem w/protobuf-3.6.x as currently it's blocking us moving to Ruby 2.6.

I'm still having issues after running this:

gem install google-protobuf --platform=ruby

It results in the same error as before, and down grading to ruby 2.5 is a pain on arch linux. Any fix?

I am currently blocked by creating gem on linux.
In our code, we depend on time.h to provide strptime. However, when compiling gem, it reports strptime is not supported.
According to https://stackoverflow.com/questions/43460876/trouble-including-function-declaration-for-strptime, I need to use -std=gnu11 to compile.
Does anyone know how to add this option to Rakefile?

@macmv Using rvm or rbenv is a good way to be able to install any Ruby version you need on your dev machine. They work on Arch Linux.

We have released 3.7.0-rc2, which supports ruby 2.6
On Sat, Feb 2, 2019 at 21:01 Matt Welke notifications@github.com wrote:

@macmv https://github.com/macmv Using rvm or rbenv is a good way to be
able to install any Ruby version you need on your dev machine. They work on
Arch Linux.

—
You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/protocolbuffers/protobuf/issues/5161#issuecomment-460023438,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AE9H5WVibXihI4FLs9Z1u7bBtyH_XjJoks5vJm01gaJpZM4WsuvV
.

Looks like 3.7.0 was released with Ruby 2.6 support.

I was able to get this to work by manually specifying the platform is ruby:

[aaron@TC ~]$ gem install google-protobuf --platform=ruby
Fetching: google-protobuf-3.6.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed google-protobuf-3.6.1
Parsing documentation for google-protobuf-3.6.1
Installing ri documentation for google-protobuf-3.6.1
Done installing documentation for google-protobuf after 3 seconds
1 gem installed
[aaron@TC ~]$ ruby -r google/protobuf -e'puts "hello"'
hello

I'm not sure if that's supported/expected, but it did get me unblocked. 😊

$ bundle config force_ruby_platform true
Was this page helpful?
0 / 5 - 0 ratings