Search code examples
rubyrequire

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


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?


Solution

  • 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.