Forum: Ruby require 'mechanize'/Ruby search path problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2006-05-16 15:08
(Received via mailing list)
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? ;-)

Thx,
Peter
9358cc96c46055cd68d4a76a9aefe026?d=identicon&s=25 Daniel Harple (Guest)
on 2006-05-16 15:26
(Received via mailing list)
On May 16, 2006, at 3:06 PM, Peter Szinek 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? ;-)

You must ``require 'rubygems''' before using an installed gem.

-- Daniel
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2006-05-16 15:33
(Received via mailing list)
> You must ``require 'rubygems''' before using an installed gem.
Thanks Daniel! It works now!
This topic is locked and can not be replied to.