Contrary to the currently accepted answer, the argument 'second.rb'
does not resolve to an absolute path. If that were what was meant, you would also be able to require 'second.rb'
, since require
has exactly the same wording about absolute paths.
I think what's happening here is just that the phrasing in the documentation for load
is not clear at all about what the actual steps are. When it says "Loads and executes the Ruby program in the file filename," it means that literally — it treats the argument as a file name and attempts to load it as a Ruby program. If isn't an absolute path†, then Ruby goes through $LOAD_PATH and looks for it in those places. If that doesn't turn anything up, then it just goes ahead and tries to open it just as you passed it in. That's the logic that MRI actually follows.
† The actual check that Ruby does is essentially "Does the path start with '/', '~' or './'?".