Require errors for rubygems

D

David Naseby

When I have multiple versions of a library in Rubygems, a normal
require will fail to pick up the latest version, and I have to do a
require_gem to use the library at all. Require works perfectly if
there is only one version of the gem installed. I'm on ruby
mswin32-1.8.2, with rubygems 0.8.1.

For example:
gem list -l activerecord
*** LOCAL GEMS ***
activerecord (1.0.0, 0.9.5, 0.9.4, 0.9.2, 0.8.1, 0.8.0, 0.7.5)
Implements the ActiveRecord pattern for ORM.
gem list -l flexmock
*** LOCAL GEMS ***
flexmock (0.0.3)
Simple and Flexible Mock Objects for Testing


irb(main):001:0> require 'flexmock'
LoadError: No such file to load -- flexmock
from (irb):1:in `require'
from (irb):1
irb(main):002:0> require 'activerecord'
LoadError: No such file to load -- activerecord
from (irb):2:in `require'
from (irb):2
irb(main):003:0> #ok, because I haven't required Rubygems, then:
irb(main):004:0* require 'rubygems'
=> true
irb(main):005:0> require 'flexmock'
=> true
irb(main):006:0> require 'activerecord'
LoadError: No such file to load -- activerecord
from c:/languages/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.
rb:5:in `require__'
from c:/languages/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.
rb:5:in `require'
from (irb):6
irb(main):007:0> require_gem 'activerecord'
=> true
 
G

Gavin Sinclair

When I have multiple versions of a library in Rubygems, a normal
require will fail to pick up the latest version, and I have to do a
require_gem to use the library at all. Require works perfectly if
there is only one version of the gem installed. I'm on ruby
mswin32-1.8.2, with rubygems 0.8.1.
[snip the most important part - d'oh!]

That's an activerecord naming issue. The gem is called 'activerecord'
but the library (what you need to require) is 'active_record'.

require_gem loads a gem. require loads a library.

Hope it works now.

Cheers,
Gavin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top