This is kinda weird for me because in the documentation there is said a
require statement tries to load a library from the $LOAD_PATH when it’s
not a absolute path and doesn’t modify it?
Is there anything else going on?
Maybe rubygems itself just includes gems to the load path if they are
required explicitly?
Adding the lib directory of a required gem to $LOAD_PATH is documented
by rubygems:
=====
Loading code
At its core, RubyGems exists to help you manage Ruby’s $LOAD_PATH, which
is how the require statement picks up new code. There’s several things
you can do to make sure you’re loading code the right way.
…
…
Mangling the load path
Gems should not change the $LOAD_PATH variable. RubyGems manages this
for you. Code like this should not be necessary:
lp = File.expand_path(File.dirname(FILE))
unless $LOAD_PATH.include?(lp)
$LOAD_PATH.unshift(lp)
end
Or:
DIR = File.dirname(FILE)
$LOAD_PATH.unshift DIR unless
$LOAD_PATH.include?(DIR) ||
$LOAD_PATH.include?(File.expand_path(DIR))
When RubyGems activates a gem, it adds your package’s lib folder to the
$LOAD_PATH ready to be required normally by another lib or application.
It is safe to assume you can then require any file in your lib folder.