On Sunday 24 July 2005 06:40, groups / jpprice.info wrote:
> >This variable is an array of directories in which Ruby
> >looks for scripts if you call require. Per default the following
> >pathes are in $LOAD_PATH:
> >  /usr/local/lib/ruby/site_ruby/?1.8
> >  /usr/local/lib/ruby/site_ruby/?1.8/i686-linux
> >  /usr/local/lib/ruby/site_ruby
> >  /usr/local/lib/ruby/1.8
> >  /usr/local/lib/ruby/1.8/i686-l?inux
>
> "Per default"... what if I install to another directory other than
> /usr/local/lib?  I'm having a problem now where I configured Ruby with
> --prefix=/home/mydirectory and none of my require statements work
> (trying to install rubygems).
>
> I'm thinking there's either something seriously wrong with Ruby or I
> need some real documentation.  Where can I find out more (online) about
> 'require' and how it finds files?

Something is wrong with your installation. I have six different
Ruby installations, five of them living somewhere under my
home directory and all work with their own libraries.
There is no magic behind require. All you need is ri:

    % ri require
--------------------------------------------------------- Kernel#require
     require(string)    => true or false
------------------------------------------------------------------------
     Ruby tries to load the library named _string_, returning +true+ if
     successful. If the filename does not resolve to an absolute path,
     it will be searched for in the directories listed in +$:+. If the
     file has the extension ``.rb'', it is loaded as a source file; if
     the extension is ``.so'', ``.o'', or ``.dll'', or whatever the
     default shared library extension is on the current platform, Ruby
     loads the shared library as a Ruby extension. Otherwise, Ruby tries
     adding ``.rb'', ``.so'', and so on to the name. The name of the
     loaded feature is added to the array in +$"+. A feature will not be
     loaded if it's name already appears in +$"+. However, the file name
     is not converted to an absolute path, so that ``+require
     'a';require './a'+'' will load +a.rb+ twice.

        require "my-library.rb"
        require "db-driver"


First ensure that the files /home/mydirectory/bin/{ruby,irb,ri}
and directory /home/mydirectory/lib/ruby exist.
Perhaps you have an older ruby (executable) on PATH. Ensure that
PATH contains /home/mydirectory/bin.
Then run `ruby -e "puts $:"'. If the pathes printed do not start
with /home/mydirectory, then the wrong ruby gets executed.
Try: `type ruby' which shows you the path to ruby which gets
executed. If it's not /home/mydirectory/bin/ruby, e.g.
/usr/local/bin/ruby, rename it to, e.g. /usr/local/bin/old_ruby.


HTH,
  Stefan