Ruby load path and gems

M

mvyver

Hi,
I'm a relative newbie to ruby and linux, so please excuse this if it
seems a little naive. Also please accept thanks for all the work that
has gone into a great language.

I thought that if '/usr/lib/ruby/1.8' was in the ruby load path "$:",
then ruby would search for a 'require'd package in subdirectories
under that directory?

for example (as root):
#gem install 'fastercsv' --install-dir='/usr/lib/ruby/1.8'

This installs without error and fastercsv.rb seems to be where it
should:
/usr/lib/ruby/1.8/gems/fastercsv-1.2.0/lib

now (still with root and the same shell session):
mv-laptop:/usr/lib/ruby/1.8 # irb
irb(main):001:0> require 'fastercsv'
LoadError: no such file to load -- fastercsv
from (irb):1:in `require'
from (irb):1
irb(main):002:0> puts $:
/usr/lib/ruby/site_ruby/1.8
/usr/lib/ruby/site_ruby/1.8/i586-linux
/usr/lib/ruby/site_ruby
/usr/lib/ruby/vendor_ruby/1.8
/usr/lib/ruby/vendor_ruby/1.8/i586-linux
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i586-linux
..
=> nil
irb(main):003:0>

Can anyone please shed some light on what I might have configured
incorrectly?

Regards
Mark
 
J

Jano Svitok

Hi,
I'm a relative newbie to ruby and linux, so please excuse this if it
seems a little naive. Also please accept thanks for all the work that
has gone into a great language.

I thought that if '/usr/lib/ruby/1.8' was in the ruby load path "$:",
then ruby would search for a 'require'd package in subdirectories
under that directory?

for example (as root):
#gem install 'fastercsv' --install-dir='/usr/lib/ruby/1.8'

This installs without error and fastercsv.rb seems to be where it
should:
/usr/lib/ruby/1.8/gems/fastercsv-1.2.0/lib

now (still with root and the same shell session):
mv-laptop:/usr/lib/ruby/1.8 # irb
irb(main):001:0> require 'fastercsv'
LoadError: no such file to load -- fastercsv
from (irb):1:in `require'
from (irb):1
irb(main):002:0> puts $:
/usr/lib/ruby/site_ruby/1.8
/usr/lib/ruby/site_ruby/1.8/i586-linux
/usr/lib/ruby/site_ruby
/usr/lib/ruby/vendor_ruby/1.8
/usr/lib/ruby/vendor_ruby/1.8/i586-linux
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i586-linux
.
=> nil
irb(main):003:0>

Can anyone please shed some light on what I might have configured
incorrectly?

Regards
Mark

Hi,

have you require'd rubygems? either require 'rubygems' or call ruby
with --rubygems or add rubygems to your $RUBYOPT variable.

I don't know how you can tell gems where to look for the files, but
from your printout it seems that gems are not loaded (you'd see
something like rubygems/custom_require in the output)

Jano
 

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,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top