Ruby Language Require files to be loaded only once


The Kernel#require method will load files only once (several calls to require will result in the code in that file being evaluated only once). It will search your ruby $LOAD_PATH to find the required file if the parameter is not an absolute path. Extensions like .rb, .so, .o or .dll are optional. Relative paths will be resolved to the current working directory of the process.

require 'awesome_print'

The Kernel#require_relative allows you to load files relative to the file in which require_relative is called.

# will search in directory myproj relative to current source file.
require_relative 'myproj/version'