module Bootsnap::ExplicitRequire
def self.from_archdir(feature)
def self.from_archdir(feature) require(File.join(ARCHDIR, "#{feature}.#{DLEXT}")) end
def self.from_rubylibdir(feature)
def self.from_rubylibdir(feature) require(File.join(RUBYLIBDIR, "#{feature}.rb")) end
def self.from_self(feature)
def self.from_self(feature) require_relative "../#{feature}" end
def self.with_gems(*gems)
This is useful before bootsnap is fully-initialized to load gems that it
temporarily remove all gems not listed in this call from the LOAD_PATH.
only core ruby source paths and these gems -- that is, roughly,
Given a set of gems, run a block with the LOAD_PATH narrowed to include
def self.with_gems(*gems) orig = $LOAD_PATH.dup $LOAD_PATH.clear gems.each do |gem| pat = %r{ / (gems|extensions/[^/]+/[^/]+) # "gems" or "extensions/x64_64-darwin16/2.3.0" / #{Regexp.escape(gem)}-(\h{12}|(\d+\.)) # msgpack-1.2.3 or msgpack-1234567890ab }x $LOAD_PATH.concat(orig.grep(pat)) end $LOAD_PATH << ARCHDIR $LOAD_PATH << RUBYLIBDIR yield ensure $LOAD_PATH.replace(orig) end