If you do
require "httparty"
ruby is searching in different locations for httparty.rb or httparty.so. Where ruby searches and in which order is stored in the global variable $:
On my debian system it looks like this:
$: # => ["/usr/local/lib/site_ruby/1.8", "/usr/local/lib/site_ruby/1.8/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.8", "/usr/lib/ruby/vendor_ruby/1.8/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/x86_64-linux", "."]
But httparty.rb is in /var/lib/gems/1.8/gems/httparty-0.4.5/lib/httparty.rb, so it can not be found. When you do
require "rubygems"
The Kernel#require method is changed, to find rubygems.
require "rubygems" makes your code platform dependant:
- Somebody might install your library through another method than rubygems
- Some linux distributions (ex. gentoo) make it uneccasary to require "rubygems"
On my debian systems I symlink every rubygems library to /usr/local/lib/site_ruby/1.8/, this path is included in the standard search path($:). You can find more about this at http://tomayko.com/writings/require-rubygems-antipattern.