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

Mark Provan picture Mark Provan · Feb 28, 2012 · Viewed 44.4k times · Source

In Ruby, I have been told that when doing

require "some_file"

Ruby will look for the file in certain places.

I know that it looks for some_file.rb, but where does it look for it by default?

Answer

Daniel Pittman picture Daniel Pittman · Feb 28, 2012

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.