Hide Forgot
Description of problem: Ruby Gems defaults to using a version-specific directory for the gem home. This allows multiple versions of Ruby to "just work" without any configuration. On RHEL6: vagrant@vagrant-smerrill:DEVELOPMENT:~> gem env home /usr/lib/ruby/gems/1.8 On OSX 10.11: ~ smerrill $ gem env home /Library/Ruby/Gems/2.0.0 On Ubuntu: skippy@three:~$ gem env home /var/lib/gems/1.9.1 But using SCL Ruby versions, the `gem` command appears to default to ~/.gem/ruby/. This means that using multiple SCL Ruby versions on a RHEL box will result in gems being co-located in the same directory. For any Ruby-only gems, this likely doesn't matter, but for any gems with native extensions it means that they may conflict with one another. First, enable an SCL Ruby and install a gem: vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable ruby200 -- gem env home /home/vagrant/.gem/ruby vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable ruby200 -- gem install example Fetching: example-1.0.2.gem (100%) Successfully installed example-1.0.2 Parsing documentation for example-1.0.2 Installing ri documentation for example-1.0.2 Done installing documentation for example after 0 seconds 1 gem installed Now enable a different SCL Ruby and examine whether that gem is available: vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable rh-ruby22 -- gem list example -d *** LOCAL GEMS *** example (1.0.2) Author: Curtis Schofield Homepage: http://github.com/robotarmy/example License: GPLv3 Installed at: /home/vagrant/.gem/ruby This is Example Note the "installed at" points to ~/.gem/ruby. Now build a gem that builds a native extension. This means the gem needs the appropriate SCL ruby-devel package, and will build against that: vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable ruby200 -- gem install rmagick Fetching: rmagick-2.15.4.gem (100%) Building native extensions. This could take a while... Successfully installed rmagick-2.15.4 Parsing documentation for rmagick-2.15.4 Installing ri documentation for rmagick-2.15.4 Done installing documentation for rmagick after 8 seconds 1 gem installed vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable ruby200 -- gem list rmagick -d *** LOCAL GEMS *** rmagick (2.15.4) Authors: Tim Hunter, Omer Bar-or, Benjamin Thomas, Moncef Maiza Homepage: https://github.com/rmagick/rmagick License: MIT Installed at: /home/vagrant/.gem/ruby Ruby binding to ImageMagick Confirm that the native extensions were built: vagrant@vagrant-smerrill:DEVELOPMENT:~> ls /home/vagrant/.gem/ruby/gems/rmagick-2.15.4/ext/RMagick/ extconf.h mkmf.log rmagick.h rmdraw.o rmfill.c rmilist.o rminfo.c rmmain.o rmpixel.c rmstruct.o extconf.rb RMagick2.so rmagick.o rmenum.c rmfill.o rmimage.c rminfo.o rmmontage.c rmpixel.o rmutil.c Makefile rmagick.c rmdraw.c rmenum.o rmilist.c rmimage.o rmmain.c rmmontage.o rmstruct.c rmutil.o Confirm that the rmagick gem works with SCL Ruby 2.0: vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable ruby200 -- irb irb(main):001:0> require 'rmagick' => true Now enable SCL Ruby 2.2 and try to use the RMagick gem: vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable rh-ruby22 -- gem list rmagick -d *** LOCAL GEMS *** rmagick (2.15.4) Authors: Tim Hunter, Omer Bar-or, Benjamin Thomas, Moncef Maiza Homepage: https://github.com/rmagick/rmagick License: MIT Installed at: /home/vagrant/.gem/ruby Ruby binding to ImageMagick vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable rh-ruby22 -- irb irb(main):001:0> require 'rmagick' LoadError: libruby.so.2.0: cannot open shared object file: No such file or directory - /home/vagrant/.gem/ruby/gems/rmagick-2.15.4/lib/RMagick2.so from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:128:in `require' from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:128:in `rescue in require' from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:39:in `require' from /home/vagrant/.gem/ruby/gems/rmagick-2.15.4/lib/rmagick_internal.rb:12:in `<top (required)>' from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/vagrant/.gem/ruby/gems/rmagick-2.15.4/lib/rmagick.rb:1:in `<top (required)>' from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:128:in `require' from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:128:in `rescue in require' from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:39:in `require' from (irb):1 from /opt/rh/rh-ruby22/root/usr/bin/irb:11:in `<main>' Version-Release number of selected component (if applicable): RHEL6 and RHEL7 SCL ruby200-rubygems SCL rh-ruby22-rubygems How reproducible: Always. Steps to Reproduce: 1. Install an SCL Ruby and rubygems packages 2. Execute `scl enable <ruby> -- gem env home 3. Examine the output Actual results: vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable ruby200 -- gem env home /home/vagrant/.gem/ruby vagrant@vagrant-smerrill:DEVELOPMENT:~> scl enable rh-ruby22 -- gem env home /home/vagrant/.gem/ruby Expected results: I would expect SCL Ruby `gem` commands to default to some directory that contains the name of the Ruby version. For example, SCL Ruby 200 would use ~/.ruby/gems/2.0/ and SCL Ruby 2.2 would use ~/.ruby/gems/2.2/ Additional info: This may be a problem with Ruby 2+ in base RHEL, trickling into SCL builds of Ruby. On a CentOS 7.1 system with no SCL Ruby installed: [vagrant@c1-smerrill ~]$ gem env home /home/vagrant/.gem/ruby
Thank you for the report. This works for Ruby 1.9.3 but it doesn't work for newer Rubies anymore. Unfortunately, looking into the code, there is no simple way around ...
I, too, cannot find any simple solution.
Red Hat does not currently plan to provide any further changes to this collection in a Red Hat Software Collections update release. This software collection is nearing the retirement date (April 2018) after which customers are encouraged to upgrade to a later release. Please contact Red Hat Support if you have further questions, or refer to the support lifecycle page for more information. https://access.redhat.com/support/policy/updates/rhscl/
In accordance with the Red Hat Software Collections Product Life Cycle, the support period for this collection has ended. New bug fix, enhancement, and security errata updates, as well as technical support services will no longer be made available for this collection. Customers are encouraged to upgrade to a later release. Please contact Red Hat Support if you have further questions, or refer to the support lifecycle page for more information. https://access.redhat.com/support/policy/updates/rhscl/