class Bootsnap::LoadPathCache::LoadedFeaturesIndex

LoadedFeaturesIndex partially mirrors an internal structure in ruby that we can’t easily obtain an interface to.

This works around an issue where, without bootsnap, ruby knows that it has already required a file by its short name (e.g. require ‘bundler’) if a new instance of bundler is added to the $LOAD_PATH which resolves to a different absolute path. This class makes bootsnap smart enough to realize that it has already loaded ‘bundler’, and not just ‘/path/to/bundler’.

If you disable LoadedFeaturesIndex, you can see the problem this solves by:

  1. ‘require ’a’‘

  2. Prepend a new $LOAD_PATH element containing an ‘a.rb`

  3. ‘require ’a’‘

Ruby returns false from step 3. With bootsnap but with no LoadedFeaturesIndex, this loads two different

`a.rb`s.

With bootsnap and with LoadedFeaturesIndex, this skips the second load,

returning false like ruby.