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

Ruby: Gem version 3.12.1 doesn't load on Ruby 2.7 or 2.6.6 with Rails 5.1.7 #7541

Closed
MatayoshiMariano opened this issue May 21, 2020 · 2 comments
Assignees
Labels

Comments

@MatayoshiMariano
Copy link

MatayoshiMariano commented May 21, 2020

What version of protobuf and what language are you using?
Version: 3.12.1
Language: Ruby

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

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

  • Ruby 2.7.1/ Rails 5.1.7
  • Ruby 2.6.6/ Rails 5.1.7

What did you do?
Steps to reproduce the behavior:

  1. CFLAGS="-Wno-cast-function-type" BUNDLE_FORCE_RUBY_PLATFORM=1 bundle update google-protobuf
  2. Run bundle exec rails server
  3. Get Load Errors, see below.

What did you expect to see
Initiate the rails server

What did you see instead?

Traceback (most recent call last):
        19: from bin/rails:4:in `<main>'
        18: from bin/rails:4:in `require'
        17: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
        16: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command.rb:44:in `invoke'
        15: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command/base.rb:63:in `perform'
        14: from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        13: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        12: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        11: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `perform'
        10: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `tap'
         9: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `block in perform'
         8: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `require'
         7: from /var/app/config/application.rb:21:in `<top (required)>'
         6: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
         5: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
         4: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
         3: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
         2: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
         1: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require': cannot load such file -- google-protobuf (LoadError)
        23: from bin/rails:4:in `<main>'
        22: from bin/rails:4:in `require'
        21: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
        20: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command.rb:44:in `invoke'
        19: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command/base.rb:63:in `perform'
        18: from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        17: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        16: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        15: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `perform'
        14: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `tap'
        13: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `block in perform'
        12: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `require'
        11: from /var/app/config/application.rb:21:in `<top (required)>'
        10: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
         9: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
         8: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
         7: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:65:in `block in require'
         6: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:88:in `rescue in block in require'
         5: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:88:in `require'
         4: from /usr/local/bundle/gems/google-protobuf-3.12.1/lib/google/protobuf.rb:49:in `<top (required)>'
         3: from /usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
         2: from /usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
         1: from /usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `block in require'
/usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- google/2.7/protobuf_c (LoadError)
        24: from bin/rails:4:in `<main>'
        23: from bin/rails:4:in `require'
        22: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
        21: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command.rb:44:in `invoke'
        20: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command/base.rb:63:in `perform'
        19: from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        18: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        17: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        16: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `perform'
        15: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `tap'
        14: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `block in perform'
        13: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `require'
        12: from /var/app/config/application.rb:21:in `<top (required)>'
        11: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'
        10: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
         9: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
         8: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:65:in `block in require'
         7: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:88:in `rescue in block in require'
         6: from /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/runtime.rb:88:in `require'
         5: from /usr/local/bundle/gems/google-protobuf-3.12.1/lib/google/protobuf.rb:48:in `<top (required)>'
         4: from /usr/local/bundle/gems/google-protobuf-3.12.1/lib/google/protobuf.rb:51:in `rescue in <top (required)>'
         3: from /usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require'
         2: from /usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:258:in `load_dependency'
         1: from /usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `block in require'
/usr/local/bundle/gems/activesupport-5.1.7/lib/active_support/dependencies.rb:292:in `require': Error relocating /usr/local/bundle/gems/google-protobuf-3.12.1/lib/google/protobuf_c.so: __va_copy: symbol not found - /usr/local/bundle/gems/google-protobuf-3.12.1/lib/google/protobuf_c.so (LoadError

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment
What does work for me is using Ruby 2.6.6, Rails 5.1.7 and google-protobuf 3.9.2

@MatayoshiMariano MatayoshiMariano changed the title Ruby: Gem version 3.12.1 doesn't load on Ruby 2.7 Ruby: Gem version 3.12.1 doesn't load on Ruby 2.7/Rails 5.1.7 May 21, 2020
@MatayoshiMariano MatayoshiMariano changed the title Ruby: Gem version 3.12.1 doesn't load on Ruby 2.7/Rails 5.1.7 Ruby: Gem version 3.12.1 doesn't load on Ruby 2.7 or 2.6.6 with Rails 5.1.7 May 21, 2020
@jcdogo
Copy link

jcdogo commented Sep 5, 2020

I was able to finally get this working with Ruby 2.6, Rails 5.2, Alpine 3.12, grcp 1.31.1, and google-protobufs 3.13.0.

Here are the relevant parts from my Dockerfile and Gemfile:

Dockerfile:

FROM ruby:2.6-alpine3.12

RUN apk add --no-cache git build-base libc6-compat nodejs

WORKDIR /usr/src/app

COPY Gemfile Gemfile.lock ./
RUN bundle config build.google-protobuf --with-cflags=-D__va_copy=va_copy
RUN BUNDLE_FORCE_RUBY_PLATFORM=1 CFLAGS="-Wno-cast-function-type" bundle install --without development:test -j4 --jobs 2 --deployment

Gemfile:

source 'https://rubygems.org'

gem 'rails', '~> 5.2.3'

gem "grpc", "~> 1.31", platforms: ["ruby"]
gem "google-protobuf", "~> 3.12", platforms: ["ruby"]

I'm not exactly sure which of the following changes (or combination of them) got everything to work, since I picked up the suggestions by following the several links in this thread:

  • libc6-compat
  • BUNDLE_FORCE_RUBY_PLATFORM=1
  • CFLAGS="-Wno-cast-function-type"
  • bundle config build.google-protobuf --with-cflags=-D__va_copy=va_copy
  • gem "grpc", "~> 1.31", platforms: ["ruby"]
  • gem "google-protobuf", "~> 3.12", platforms: ["ruby"]

But in the end, this combination actually compiles without errors and also runs without segfaulting.

@haberman
Copy link
Member

Hmm, that is odd, not sure what happened there.

The newest version of the code no longer uses va_copy(), so this shouldn't be an issue any more as of #8184 and 3.15.0-rc1.

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

No branches or pull requests

4 participants