All,

> /usr/bin/mongrel_cluster_ctl:9:in `require': no such file to load --
> [...] I have tried adding /usr/local/bin to the path; didn't work

A similar thing happened to me when I was testing a Ruby-based startup 
(/etc/init.d) script and was getting failures on my "load" command 
(similar symptoms to David's failure on "require".

I looked at the failure using strace and noticed that the final library 
lookup for say xxx.rb would be ./xxx.rb. This made me wonder what the 
current working directory was and it seems that scripts started with 
/sbin/service are started in the directory "/". So unless your loaded or 
required script is in "/" it will fail. Here is what the contents of var 
$: look like on my machine that seem to confirm this (this is the load 
order):

/usr/lib/ruby/site_ruby/1.8
/usr/lib/ruby/site_ruby/1.8/i386-linux
/usr/lib/ruby/site_ruby
/usr/lib/site_ruby/1.8
/usr/lib/site_ruby/1.8/i386-linux
/usr/lib/site_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i386-linux
.

Notice that "." (current dir is the last one). I tried adding 
/etc/init.d (where my other scripts were for startup) using: 
$:.unshift("/etc/init.d") to dynamically change the search order and 
ended up with this, which worked:

/etc/init.d
/usr/lib/ruby/site_ruby/1.8
/usr/lib/ruby/site_ruby/1.8/i386-linux
/usr/lib/ruby/site_ruby
/usr/lib/site_ruby/1.8
/usr/lib/site_ruby/1.8/i386-linux
/usr/lib/site_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i386-linux
.

Now I can keep the whole thing Ruby-based without having to change the 
/sbin/service code or resort to bash startup scripts to kick things 
off...

The section entitled "Where Ruby Finds Its Modules" in the Programming 
Ruby book (http://www.ruby-doc.org/docs/ProgrammingRuby/) was helpful to 
me in understanding this.

Hope this helps the next victim.
-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Mongrel-users mailing list
Mongrel-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-users

Reply via email to