25Sep/070
Including Ruby Gems in Scripts
For quite a while, I was trying to write a ruby script to print some growl messages. I was having a hard time loading the growl code, using the "require 'ruby-growl'" syntax. I started digging around and looking at ruby's load path.
nicks-computer:~/Desktop/depot nick$ irb irb(main):001:0> puts $: /usr/local/lib/ruby/site_ruby/1.8 /usr/local/lib/ruby/site_ruby/1.8/i686-darwin8.9.1 /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.8 /usr/local/lib/ruby/1.8/i686-darwin8.9.1 . => nil
After a while, I got it working and left it as
require '/usr/lib/ruby/gems/1.8/gems/ruby-growl-1.0.1/lib/ruby-growl.rb'
A couple months later I opened the script again, and laughed. Hahaha. Its as easy as
require 'rubygems' require 'ruby-growl