Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jan 2010 05:18:04 GMT
From:      Aaron Gifford <astounding@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/143337: Ruby 1.9.1 gems installed with RUBY_VERSION=1.9.1 set in make.conf fail to load with LoadError
Message-ID:  <201001290518.o0T5I4FU041087@www.freebsd.org>
Resent-Message-ID: <201001290520.o0T5KAAL073315@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         143337
>Category:       ports
>Synopsis:       Ruby 1.9.1 gems installed with RUBY_VERSION=1.9.1 set in make.conf fail to load with LoadError
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 29 05:20:10 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Aaron Gifford
>Release:        FreeBSD 8.0-STABLE as of 27 Jan. 2010
>Organization:
>Environment:
FreeBSD host.example.com 8.0-STABLE FreeBSD 8.0-STABLE #0: Wed Jan 27 19:46:39 MST 2010     root@host.example.com:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
When using Ruby 1.9.1 as the default ruby version (by setting RUBY_VERSION=1.9.1 in /etc/make.conf), gems installed via the ports system OR installed directly with the gem command fail to load when required with a LoadError.

Please see the thread at http://forums.freebsd.org/showthread.php?t=10760 for example details.  Also see the email thread in the freebsd-ruby@freebsd.org archives on 28 Jan. 2010.

The problem can be traced to a discrepancy in the default gem path.  Call the Gem.default_dir method within Ruby 1.9.1 on a FreeBSD host with the ruby19 port installed, and you will see:

% ruby -e 'p Gem.default_dir'
"/usr/local/lib/ruby19/gems/1.9"

That is NOT right.  It should be "/usr/local/lib/ruby/gems/1.9" instead.  If you install one or more gems with the port system (by setting RUBY_VERSION=1.9.1 in /etc/make.conf so that ruby19 is the default ruby version), OR if you use the gem command to install directly from a .gem file, then look where the gems get installed, they are installed in "/usr/local/lib/ruby/gems/1.9" and NOT where the Gem.default_dir claims they are.

The problem can be fixed with a one-line patch that should work regardless if 1.9 is the default or not.  (See patch in this PR submission.)
>How-To-Repeat:
Install Ruby 1.9.1 via the ports collection.  If you don't want to make Ruby 1.9.1 your default Ruby installation, you can repeat the problem by downloading a pure ruby .gem file and installing it directly.  For example:

user@host:/path# fetch http://www.aarongifford.com/computers/mtik/latest/mtik-3.0.1.gem
mtik-3.0.1.gem                                100% of   17 kB   93 kBps
user@host:/path# gem19 install mtik-3.0.1.gem 
Successfully installed mtik-3.0.1
1 gem installed
Installing ri documentation for mtik-3.0.1...
Updating class cache with 1372 classes...
Installing RDoc documentation for mtik-3.0.1...
user@host:/path# irb19
irb(main):001:0> require 'mtik'
LoadError: no such file to load --  mtik
       from (irb):2:in `require'
       from (irb):2
       from /usr/local/bin/irb:12:in `<main>'
irb(main):002:0>



>Fix:
Patch the gem_prelude.rb file as follows:
==========
--- gem_prelude.rb.orig	2010-01-28 21:22:27.307910440 -0700
+++ gem_prelude.rb	2010-01-28 21:22:43.177946726 -0700
@@ -116,7 +116,7 @@
         File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
                   ConfigMap[:ruby_version]
       elsif RUBY_VERSION > '1.9' then
-        File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
+        File.join(ConfigMap[:libdir], 'ruby', 'gems',
                   ConfigMap[:ruby_version])
       else
         File.join(ConfigMap[:libdir], ruby_engine, 'gems',
==========

Replace ConfigMap[:ruby_install_name] (value "ruby19") with the literal string 'ruby' and all is well.

This is one possible solution of several, probably the simplest.

Patch attached with submission follows:

--- gem_prelude.rb.orig	2010-01-28 21:22:27.307910440 -0700
+++ gem_prelude.rb	2010-01-28 21:22:43.177946726 -0700
@@ -116,7 +116,7 @@
         File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
                   ConfigMap[:ruby_version]
       elsif RUBY_VERSION > '1.9' then
-        File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
+        File.join(ConfigMap[:libdir], 'ruby', 'gems',
                   ConfigMap[:ruby_version])
       else
         File.join(ConfigMap[:libdir], ruby_engine, 'gems',


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001290518.o0T5I4FU041087>