Skip to content

Commit

Permalink
Fix bootsnap setup in environments without bundler
Browse files Browse the repository at this point in the history
Fix: #488

`ExplicitRequire.with_gems` assumed the provided gems were activated
which is only true if `bundler/setup` was required.

If bootsnap is used without bundler, then we need to explictly
activate the gem before mutating the `$LOAD_PATH`, otherwise
the paths appended during gems activation will be lost once we
exit `with_gems`.
  • Loading branch information
byroot committed Jul 17, 2024
1 parent c5513d9 commit bac4e74
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/bootsnap/explicit_require.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def self.from_archdir(feature)
# This is useful before bootsnap is fully-initialized to load gems that it
# depends on, without forcing full LOAD_PATH traversals.
def self.with_gems(*gems)
# Ensure the gems are activated (their paths are in $LOAD_PATH)
gems.each do |gem_name|
gem gem_name
end

orig = $LOAD_PATH.dup
$LOAD_PATH.clear
gems.each do |gem|
Expand Down

0 comments on commit bac4e74

Please sign in to comment.