On Jun 16, 2011, at 04:29 , Piotr Szotkowski wrote: > I understand that for require to work relative to the given __FILE__ÃÔirectory one needs to either $LOAD_PATH << File.dirname(__FILE__) or > use require_relative (with the latter being preferred, I presume). > > Is there such an alternative for Kernel#autoload > and if not, should there be one? > > IÃÎ thinking about lib/foo.rb containing > > module Foo > autoload :Bar, 'foo/bar.rb' > autoload :Baz, 'foo/baz.rb' > autoload :Qux, 'foo/qux.rb' > end > > (which doesnÃÕ work without $LOAD_PATH munging), I wouldn't call having 'lib' in your LOAD_PATH as munging. I'd call that business as usual. Rubygems supports that as a default. All the usual rake tasks and test tools support that as a default. It just seems sane to me... Much more sane than File.dirname(__FILE__) does or require_relative. (btw, you don't need the ".rb" part--that's just ugly) > as > opposed to the (currently working) lib/foo.rb with > > require_relative 'foo/bar.rb' > require_relative 'foo/baz.rb' > require_relative 'foo/qux.rb' again, ".rb" not needed.