How Ruby Finds Libraries

In Ruby not library management is not always as simple as running gem install.
Some Ruby code is distributed simply as libraries. So where do you put these libraries? The clue is
in the Ruby $LOAD_PATH variable.

	irb(main):001:0> puts $LOAD_PATH
	/usr/local/lib/ruby/site_ruby/1.8
	/usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.10.1
	/usr/local/lib/ruby/site_ruby
	/usr/local/lib/ruby/1.8
	/usr/local/lib/ruby/1.8/i686-darwin8.10.1
	.
	=> nil
	irb(main):002:0>

This tells you that you can put your library code in any of the above listed directories and
if Ruby still can’t find the code it will try the current directory you’re running code in before
giving up.

Personally I end up using the /usr/local/lib/ruby/1.8 folder.

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.