Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jan 2010 12:33:34 -0700
From:      Aaron Gifford <astounding@gmail.com>
To:        freebsd-ruby@freebsd.org
Subject:   Ruby Gem Require LoadError (8-STABLE, Ruby 1.9.1)
Message-ID:  <e58000751001281133v42a6613dm61a0c2c7922df93d@mail.gmail.com>

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

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

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

------
#!/usr/local/bin/ruby19

require 'rubygems'
require 'net/ssh'

...

------

The script fails with:

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

So of course I check my gems install:
------
user@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@host:/home/user# gem19 environment
RubyGems Environment:
=A0- RUBYGEMS VERSION: 1.3.1
=A0- RUBY VERSION: 1.9.1 (2009-12-07 patchlevel 376) [amd64-freebsd8]
=A0- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9
=A0- RUBY EXECUTABLE: /usr/local/bin/ruby19
=A0- EXECUTABLE DIRECTORY: /usr/local/bin
=A0- RUBYGEMS PLATFORMS:
=A0 =A0- ruby
=A0 =A0- amd64-freebsd-8
=A0- GEM PATHS:
=A0 =A0 - /usr/local/lib/ruby/gems/1.9
=A0 =A0 - /home/user/.gem/ruby/1.9
=A0- GEM CONFIGURATION:
=A0 =A0 - :update_sources =3D> true
=A0 =A0 - :verbose =3D> true
=A0 =A0 - :benchmark =3D> false
=A0 =A0 - :backtrace =3D> false
=A0 =A0 - :bulk_threshold =3D> 1000
=A0- REMOTE SOURCES:
=A0 =A0 - http://gems.rubyforge.org/
user@host:/home/user% pkg_info | grep ruby
ruby-1.9.1,1 =A0 =A0 =A0 =A0An object-oriented interpreted scripting langua=
ge
ruby19-iconv-1.9.1,1 An iconv wrapper class for Ruby
ruby19-mysql-2.8.1 =A0Ruby module for accessing MySQL databases with a C AP=
I 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 =A0 =A0Ruby interface to PostgreSQL library
rubygem-sqlite3-1.2.5 Ruby interface to the SQLite DB engine version 3
user@host:/home/user% uname -av
FreeBSD host.example.org 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 =A0amd64
user@host:/home/user%
------

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

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

Now THAT's interesting. =A0If I use the gem method before the require,
the gem is found. =A0But ONLY after.

Anyone have any ideas?

Puzzled,
Aaron out.



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