What are the paths that "require" looks up by default?

It depends on your platform, and how Ruby was compiled, so there is no "the" answer to this. You can find out by running:

ruby -e 'puts $:'

Generally, though, you have the standard, site, and vendor Ruby library paths, including an arch, version, and general directory under each.


additional paths can be specified by setting RUBYLIB environment variable


Ruby looks in all the paths specified in the $LOAD_PATH array.

You can also add a directory to search like so:

$LOAD_PATH.unshift File.expand_path('../path/from/this/file/to/another/directory', __FILE__)

Tags:

Ruby

Require