module Bootsnap::LoadPathCache

Constants

CACHED_EXTENSIONS
DLEXT
DLEXT2

This is nil on linux and darwin, but I think it's '.o' on some other platform. I'm not really sure which, but it seems better to replicate ruby's semantics as faithfully as possible.

DL_EXTENSIONS
DOT_RB
DOT_SO
ERROR_TAG_IVAR

If a NameError happens several levels deep, don't re-handle it all the way up the chain: mark it once and bubble it up without more retries.

FallbackScan
ReturnFalse
SLASH

Attributes

autoload_paths_cache[R]
load_path_cache[R]
loaded_features_index[R]
realpath_cache[R]

Public Class Methods

setup(cache_path:, development_mode:, active_support: true) click to toggle source
# File lib/bootsnap/load_path_cache.rb, line 34
def setup(cache_path:, development_mode:, active_support: true)
  unless supported?
    warn("[bootsnap/setup] Load path caching is not supported on this implementation of Ruby") if $VERBOSE
    return
  end

  store = Store.new(cache_path)

  @loaded_features_index = LoadedFeaturesIndex.new
  @realpath_cache = RealpathCache.new

  @load_path_cache = Cache.new(store, $LOAD_PATH, development_mode: development_mode)
  require_relative('load_path_cache/core_ext/kernel_require')
  require_relative('load_path_cache/core_ext/loaded_features')

  if active_support
    # this should happen after setting up the initial cache because it
    # loads a lot of code. It's better to do after +require+ is optimized.
    require('active_support/dependencies')
    @autoload_paths_cache = Cache.new(
      store,
      ::ActiveSupport::Dependencies.autoload_paths,
      development_mode: development_mode
    )
    require_relative('load_path_cache/core_ext/active_support')
  end
end
supported?() click to toggle source
# File lib/bootsnap/load_path_cache.rb, line 62
def supported?
  RUBY_ENGINE == 'ruby' &&
  RUBY_PLATFORM =~ /darwin|linux|bsd/
end