Library path relative to current .rb file

One of the most irritating (missing) features of Ruby is inability to
’require’ files in the same directory or subdirectories as the
executing source file. In other programming languages (Java, C, C++)
that is commonly used. Note that this is different from the current
woriking directory.

I do not want to add the directory of the currenty executing file to
the library path because that would apply to all the other files,
including standard library (e.g. I usually have ‘utils.rb’ in every
project, and that would make a confusion if I tried to use two

$LOAD_PATH << File.dirname($0) # VERY BAD - does not work for
$LOAD_PATH << File.dirname(FILE) # Also VERY BAD - huge

The solution is to prepend current file’s directory before every
’require’, which is very ugly.

require File.join(File.dirname(FILE), ‘utils’ ) # UGLY

My question is:

  • Why aren’t required files looked up in subdirectories relative to
    the current file?
  • Is there an easy way to simulate that in Ruby?
  • Can it be easily fixed in Ruby interpreter source code?