Ruby Gem Require LoadError (8-STABLE, Ruby 1.9.1)

Aaron Gifford astounding at
Thu Jan 28 19:59:39 UTC 2010


I'm running a fresh install of FreeBSD 8-STABLE (installed then
updated to STABLE as of 27 Jan. 2010).  All ports are freshly built
and installed.

After installing Ruby 1.9.1 and several gems via the Ports collection,
ruby scripts that use the gems fail to load:


require 'rubygems'
require 'net/ssh'



The script fails with:

user at host:/home/user% ./script.rb
./script.rb:4:in `require': no such file to load -- net/ssh (LoadError)
       from ./script.rb:4:in `<main>'

So of course I check my gems install:
user at host:/home/user% gem list --local

*** LOCAL GEMS ***

activerecord (2.3.4)
activesupport (2.3.4)
net-ssh (2.0.15)
pg (0.8.0)
sqlite3-ruby (1.2.5)
user at host:/home/user# gem19 environment
RubyGems Environment:
 - RUBY VERSION: 1.9.1 (2009-12-07 patchlevel 376) [amd64-freebsd8]
 - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9
 - RUBY EXECUTABLE: /usr/local/bin/ruby19
 - EXECUTABLE DIRECTORY: /usr/local/bin
   - ruby
   - amd64-freebsd-8
    - /usr/local/lib/ruby/gems/1.9
    - /home/user/.gem/ruby/1.9
    - :update_sources => true
    - :verbose => true
    - :benchmark => false
    - :backtrace => false
    - :bulk_threshold => 1000
user at host:/home/user% pkg_info | grep ruby
ruby-1.9.1,1        An object-oriented interpreted scripting language
ruby19-iconv-1.9.1,1 An iconv wrapper class for Ruby
ruby19-mysql-2.8.1  Ruby module for accessing MySQL databases with a C API like
rubygem-activerecord-2.3.4_1 Object-relational mapping layer for Rails
MVC Framework
rubygem-activesupport-2.3.4_1 Utility classes and extension that are
required by Rails MV
rubygem-net-ssh-2.0.15 Non-interactive SSH processing
rubygem-pg-0.8.0    Ruby interface to PostgreSQL library
rubygem-sqlite3-1.2.5 Ruby interface to the SQLite DB engine version 3
user at host:/home/user% uname -av
FreeBSD 8.0-STABLE FreeBSD 8.0-STABLE #0: Wed Jan 27
19:46:39 MST 2010
root at  amd64
user at host:/home/user%

ALL installed gems fail to load with the exact same error.  So I
think, perhaps it's the FreeBSD port system gems that are bad.  I
download a new gem and install it with the gem command (bypassing
ports).  But when I try to require it, it fails with the exact same

All of the installed gems (whether by ports or by direct gem install)
are in the correct install location (/usr/local/lib/ruby/gems/1.9/)
and are present.

Then I learn this:

user at host:/home/user% irb19
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'net/ssh'
LoadError: no such file to load -- net/ssh
       from (irb):2:in `require'
       from (irb):2
       from /usr/local/bin/irb:12:in `<main>'
irb(main):003:0> require 'active_record'
LoadError: no such file to load -- active_record
       from (irb):3:in `require'
       from (irb):3
       from /usr/local/bin/irb:12:in `<main>'
irb(main):004:0> gem 'net-ssh'
=> true
irb(main):005:0> require 'net/ssh'
=> true
irb(main):006:0> require 'active_record'
LoadError: no such file to load -- active_record
       from (irb):6:in `require'
       from (irb):6
       from /usr/local/bin/irb:12:in `<main>'
irb(main):007:0> gem 'activerecord'
=> true
irb(main):008:0> require 'active_record'
=> true

Now THAT's interesting.  If I use the gem method before the require,
the gem is found.  But ONLY after.

Anyone have any ideas?

Aaron out.

More information about the freebsd-ruby mailing list