Is there a rubygems require and an ordinary require?
The salient point is that require depends on your LOAD_PATH. There are
many ways to inspect your load path, for example, you can start irb and
look at the $: global variable. If you use require with a name like
‘string_extensions’ it searches your load path for a matching file (it
adds ‘rb’ or the appropriate extension file extension automatically).
Basically, you can think of requiring ‘rubygems’ as adding all your
installed gems to the load path so that they will be found if you
require them.
Most developers (in my experience) discourage the use of explicitly
requiring ruby gems in libraries. For a detailed explanation see:
Whenever you require one of your files and it can’t be found, it means
that the file isn’t in your current load path. For that reason, Ryan
Davis above suggested you use ruby -I. (this explicitly adds your
working directory to the load path) and Luke Gruber explained how you
can use require with an absolute path.
1.Actually, a ruby library is a ruby file, the require method will
checks the file with the .rb suffix, and the path of the file. the
path of the require file maybe in current directory, or rubygems
directory.
2.The ruby interpreter(>1.9.2) includes the rubygems lib, so you not
really need to require it.