From: Robert Klemme Date: 2009-10-14T23:51:07+09:00 Subject: Re: Hey you! Stop using relative requires! 2009/10/14 Anthony Metcalf : > Louis-Philippe wrote: >> for further clarification read: >> http://gist.github.com/54177 >> >> and >> >> http://www.untilnil.com/2009/02/25/require-principle_of_least_surprise >> >> >> >> 2009/10/14 Anthony Metcalf >> > Thanks for the links. They are interesting. > > Does make the require statements a wee bit wacky though, do people > really use > > require File.join( File.dirname( File.expand_path(__FILE__)), 'lib', > 'helpers', 'precious') > > rather than > > require 'lib/helpers/precious' I believe there is a mistake: the second require should read # file /mygem/lib/helpers.rb require File.join( File.dirname( File.expand_path(__FILE__)), 'helpers', 'precious') i.e. the "lib" is superfluous since helpers.rb does reside in lib already. Whether people use that much I can't say. I believe usually require 'helpers/precious' is safe because if the load path is such that the initial helpers.rb is found then it will also find the correct precious.rb with the relative path. I do believe though that the absolute path is more robust especially when using an explicit path to require the library root file. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/