[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby load path and gems

mvyver

3/22/2007 10:54:00 PM

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

1 Answer

Jano Svitok

3/22/2007 11:10:00 PM

0

On 3/22/07, mvyver@gmail.com <mvyver@gmail.com> wrote:
> 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