Skip to content
instance method

Kernel#require

(::String path) -> bool
require(path)

When RubyGems is required, Kernel#require is replaced with our own which is capable of loading gems on demand.

When you call require 'x', this is what happens:

  • If the file can be loaded from the existing Ruby loadpath, it is.

  • Otherwise, installed gems are searched for a file that matches. If it’s found in gem ‘y’, that gem is activated (added to the loadpath).

The normal require functionality of returning false if that file has already been loaded is preserved.

See also #readlines #require_relative #readline #select also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0