From: Patrick Doyle Date: 2008-10-08T04:29:18+09:00 Subject: load vs require ------=_Part_57622_25297380.1223407878999 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I started looking through the source code for rake and noticed something curious. I see that when I execute the "rake" command at the command prompt, I run a fairly trivial ruby script: require 'rubygems' version = ">= 0" if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then version = $1 ARGV.shift end gem 'rake', version load 'rake' The #gem method prepended "..../gems/rake-0.8.3/bin" and ".../gems/rake-0.8.3/lib" to my $LOAD_PATH (the "bin" directory first). Thus, when the script invokes the #load method, it grabs "..../gems/rake-0.8.3/bin/rake" and starts to execute it. It looks like this: begin require 'rake' rescue LoadError require 'rubygems' require 'rake' end Rake.application.run Somehow, the "#require" method knows that it should load the "rake.rb" file from the "lib" directory (the second element in $LOAD_PATH) instead of the already loaded "rake" from the "bin" directory, (the fist element in $LOAD_PATH). Why is that? --wpd ------=_Part_57622_25297380.1223407878999--