Got a Question to $LOAD_PATH.
When using require ‘mygem’ in the ruby documentation is written:
“If the filename does not resolve to an absolute path, it will be
searched for in the directories listed in $LOAD_PATH”
But when i output the $LOAD_PATH before the require statement on mri
2.1.1 i got following:
/home/benny/.rubies/mri-2.1.1/lib/ruby/site_ruby/2.1.0
/home/benny/.rubies/mri-2.1.1/lib/ruby/site_ruby/2.1.0/x86_64-linux
/home/benny/.rubies/mri-2.1.1/lib/ruby/site_ruby
/home/benny/.rubies/mri-2.1.1/lib/ruby/vendor_ruby/2.1.0
/home/benny/.rubies/mri-2.1.1/lib/ruby/vendor_ruby/2.1.0/x86_64-linux
/home/benny/.rubies/mri-2.1.1/lib/ruby/vendor_ruby
/home/benny/.rubies/mri-2.1.1/lib/ruby/2.1.0
/home/benny/.rubies/mri-2.1.1/lib/ruby/2.1.0/x86_64-linux
After the require statment for example i wanna use stackprof the
$LOAD_PATH is:
/home/benny/.gem/ruby/2.1.1/extensions/x86_64-linux/2.1.0-static/stackprof-0.2.6
/home/benny/.gem/ruby/2.1.1/gems/stackprof-0.2.6/lib
/home/benny/.rubies/mri-2.1.1/lib/ruby/site_ruby/2.1.0
/home/benny/.rubies/mri-2.1.1/lib/ruby/site_ruby/2.1.0/x86_64-linux
/home/benny/.rubies/mri-2.1.1/lib/ruby/site_ruby
/home/benny/.rubies/mri-2.1.1/lib/ruby/vendor_ruby/2.1.0
/home/benny/.rubies/mri-2.1.1/lib/ruby/vendor_ruby/2.1.0/x86_64-linux
/home/benny/.rubies/mri-2.1.1/lib/ruby/vendor_ruby
/home/benny/.rubies/mri-2.1.1/lib/ruby/2.1.0
/home/benny/.rubies/mri-2.1.1/lib/ruby/2.1.0/x86_64-linux
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?