Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf can't be required on Ruby 2.6 #5161

Closed
tenderlove opened this issue Sep 17, 2018 · 14 comments
Closed

Protobuf can't be required on Ruby 2.6 #5161

tenderlove opened this issue Sep 17, 2018 · 14 comments

Comments

@tenderlove
Copy link
Contributor

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!

@tenderlove
Copy link
Contributor Author

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. 😊

mostlyobvious added a commit to RailsEventStore/rails_event_store that referenced this issue Sep 21, 2018
At the moment google-protobuf has issues building on Ruby 2.6 (protocolbuffers/protobuf#5161)
We don't however want to skip other tests in 3 most important gems.

Added test to fail when such skips are no longer needed.

Closes #431
@blowmage
Copy link
Contributor

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.

mostlyobvious added a commit to RailsEventStore/rails_event_store that referenced this issue Nov 26, 2018
One can install (and successfully require) google-protobuf on Ruby 2.6
when specifying build platform:
protocolbuffers/protobuf#5161 (comment)

That however does not play well with Bundler. I did not manage to
override platform for single gem in bundle (being on OSX) nor to make
bundler use pre-built gem for different platform.

Apparently correctly pre-built gems will land in Feb:
protocolbuffers/protobuf#5161 (comment)

Similar kertuffle for JRuby:
protocolbuffers/protobuf#1594

I'd rather skip it altogether now and re-evaluate in the future.

[#431]
[#432]
[#461]
@TeBoring TeBoring added this to the v3.7.0 milestone Dec 1, 2018
olleolleolle added a commit to koic/cucumber-ruby that referenced this issue Jan 1, 2019
  - and it requires special installation from protocolbuffers/protobuf#5161
mostlyobvious added a commit to RailsEventStore/rails_event_store that referenced this issue Jan 2, 2019
This allows mutation/testing on Ruby 2.6.

Related:
https://twitter.com/pawelpacana/status/1080576829872844801
protocolbuffers/protobuf#5161

Private source to be removed once there's an official update on
rubygems.org.

Building https://github.com/protocolbuffers/protobuf:
1. compile C++ version to have src/proto ready for use
2. on macos: rake build clobber_package gem gem:native
3. on linux: rake build clobber_package gem gem:native as well, but make
   sure to update rake-compiler* dependencies to newest ones, update
   RUBY_CC_VERSION to include 2.6.0 and disable non-linux from ext.cross_platform
mostlyobvious added a commit to RailsEventStore/rails_event_store that referenced this issue Jan 2, 2019
This allows mutation/testing on Ruby 2.6.

Related:
https://twitter.com/pawelpacana/status/1080576829872844801
protocolbuffers/protobuf#5161

Private source to be removed once there's an official update on
rubygems.org.

Building https://github.com/protocolbuffers/protobuf:
1. compile C++ version to have src/proto ready for use
2. on macos: rake build clobber_package gem gem:native
3. on linux: rake build clobber_package gem gem:native as well, but make
   sure to update rake-compiler* dependencies to newest ones, update
   RUBY_CC_VERSION to include 2.6.0 and disable non-linux from ext.cross_platform
@TeBoring
Copy link
Contributor

TeBoring commented Jan 3, 2019

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

@TeBoring
Copy link
Contributor

TeBoring commented Jan 3, 2019

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

@TeBoring
Copy link
Contributor

TeBoring commented Jan 8, 2019

Fixed by #5537

@TeBoring TeBoring closed this as completed Jan 8, 2019
@mostlyobvious
Copy link

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

@romansklenar
Copy link

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

@stephenh
Copy link

stephenh commented Jan 8, 2019

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.

@macmv
Copy link

macmv commented Jan 23, 2019

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?

@TeBoring
Copy link
Contributor

TeBoring commented Feb 1, 2019

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?

@mattwelke
Copy link

@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.

@TeBoring
Copy link
Contributor

TeBoring commented Feb 3, 2019 via email

@breisig
Copy link

breisig commented May 3, 2019

Looks like 3.7.0 was released with Ruby 2.6 support.

@stAndrei
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests