Require 'mechanize'/Ruby search path problem

Hello all,

i have installed mechanize from a gem:

sudo gem install mechanize

and it went OK, as far as i am concerned.

However, when i am trying to run any example from the mechanize RDoc, i
am getting the following error:

LoadError: no such file to load – mechanize

my $: is
irb(main):010:0> $:
=> ["/usr/local/lib/site_ruby/1.8",
“/usr/local/lib/site_ruby/1.8/i486-linux”,
“/usr/local/lib/site_ruby/1.8/i386-linux”, “/usr/local/lib/site_ruby”,
“/usr/lib/ruby/1.8”, “/usr/lib/ruby/1.8/i486-linux”,
“/usr/lib/ruby/1.8/i386-linux”, “.”]

and i have looked up mechanize manually, it’s in

/usr/lib/ruby/gems/1.8/gems/mechanize-0.4.4

i.e. not in $:

Where is the problem? Should not this be automatic? (i.e. that if you
install a gem, it is installed to a place which is in $:, or the $: is
updated to contain the installed gem path (/usr/lib/ruby/gems/1.8/gems/
in my case)?

Or i am doing something terribly wrong? :wink:

Thx,
Peter

On May 16, 2006, at 3:06 PM, Peter S. wrote:

Where is the problem? Should not this be automatic? (i.e. that if
you install a gem, it is installed to a place which is in $:, or
the $: is updated to contain the installed gem path (/usr/lib/ruby/
gems/1.8/gems/ in my case)?

Or i am doing something terribly wrong? :wink:

You must ``require ‘rubygems’’’ before using an installed gem.

– Daniel

You must ``require ‘rubygems’’’ before using an installed gem.
Thanks Daniel! It works now!