Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x-yuri/df54d169a4955833195bd7ba75b6549a to your computer and use it in GitHub Desktop.
Save x-yuri/df54d169a4955833195bd7ba75b6549a to your computer and use it in GitHub Desktop.
ruby: ignoring gems because extensions are not built (2.6.x <-> 2.7.x, docker).md

ruby: ignoring gems because extensions are not built (2.6.x <-> 2.7.x, docker)

Since ruby-2.7.0 Gem::Platform.local.to_s == 'x86_64-linux-musl'. As such the extensions dir changes from /usr/local/bundle/extensions/x86_64-linux to /usr/local/bundle/extensions/x86_64-linux-musl. As such if you switch from 2.7.x to 2.6.x or back you will see the following warning for gems with native extensions:

Ignoring byebug-11.1.3 because its extensions are not built. Try: gem pristine byebug --version 11.1.3

https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/basic_specification.rb#L79-L80
https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/specification.rb#L2181
https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/stub_specification.rb#L146
https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/basic_specification.rb#L50
https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/basic_specification.rb#L98
https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/basic_specification.rb#L106
https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/platform.rb#L15-L17
https://github.com/ruby/ruby/blob/v3_2_2/lib/rubygems/platform.rb#L105

Gemfile:

source 'https://rubygems.org'
gem 'byebug', '11.1.3'

a.sh:

ruby_from=$1
ruby_to=$2
docker run --rm -it \
    -v "$PWD:/app" \
    -w /app \
    -e GEM_HOME=/app/bundle \
    "$ruby_from" \
sh -euxc '
    ruby -e "p Gem::Platform.local.to_s"
    rm -rf Gemfile.lock bundle
    apk add build-base
    if ruby -e "if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(\"2.7.0\"); then exit(1); end"; then
        gem install bundler -v "~> 2.0"
    fi
    bundle
    bundle exec ruby -rbyebug -e ""
'
docker run --rm -it \
    -v "$PWD:/app" \
    -w /app \
    -e GEM_HOME=/app/bundle \
    "$ruby_to" \
sh -euxc '
    ruby -e "p Gem::Platform.local.to_s"
    if ruby -e "if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(\"2.7.0\"); then exit(1); end"; then
        gem install bundler -v "~> 2.0"
    fi
    bundle exec ruby -rbyebug -e ""
'
$ sh -eu a.sh ruby:2.6.10-alpine3.15 ruby:2.7.0-alpine3.10
...
+ bundle exec ruby -rbyebug -e 
Ignoring byebug-11.1.3 because its extensions are not built. Try: gem pristine byebug --version 11.1.3
Traceback (most recent call last):
        1: from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
        /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- byebug (LoadError)

$ sh -eu a.sh ruby:2.7.0-alpine3.10 ruby:2.6.10-alpine3.15
...
+ bundle exec ruby -rbyebug -e 
Your RubyGems version (3.0.3.1) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system 3.2.3`
Ignoring byebug-11.1.3 because its extensions are not built. Try: gem pristine byebug --version 11.1.3
/usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- byebug (LoadError)
        from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment