On 2006-03-31 10:52:55 -0800, Stephen Tashiro <tashiro / zianet.com> said:

> 
> I see, by experiment, that one can maipulate $LOAD_PATH within a Ruby 
> program.  The second edition of the Pixaxe book indicates that using 
> rubygems is a good way.
> 
> What are some examples of "best practices" for $LOAD_PATH management?

Rails handles this very well, I've duplicated it in my own projects and 
have had great success.

What rails does is unshift onto the load path based on the directory of 
the current file, require the files necessary, then shift that item off 
the load path (to keep duplicate filenames from being improperly 
loaded).

It looks something (although you may want to read the Rails source) like this:

$:.unshift(File.dirname(__FILE__) + "/whatever")
require "foo"
require "bar"
require "etc"
$:.shift

The nice thing about this situation is that you can easily re-require 
whole projects in irb by loading the file that contains this statement, 
and leave your environment effectively clean after you're done.