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 7afa951
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

* Allow using bootsnap without bundler. See #488.
* Fix startup failure if the cache directory points to a broken symlink.

# 1.18.3
Expand Down
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 7afa951

Please sign in to comment.