Skip to content

Commit 6336140

Browse files
luke-grubereightbitraptor
authored andcommitted
Fix issues with require "bundler/setup"
If your ruby's bundler is different from the saved result in `Gemfile.lock`, bundler autoswitches by starting a new process. When it does this it sometimes doesn't pick up the old LOAD_PATH and results in a LoadError. Switch to use `Bundler.setup`, which is a simpler process and uses the current bundler.
1 parent 3c21aea commit 6336140

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

harness/harness-common.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ def use_gemfile(extra_setup_cmd: nil)
4444
setup_cmds(["bundle check 2> /dev/null || bundle install", extra_setup_cmd].compact)
4545

4646
# Need to be in the appropriate directory for this...
47-
require "bundler/setup"
47+
require "bundler"
48+
# Use Bundler.setup instead of require 'bundler/setup' to avoid bundler's autoswitch restarting the
49+
# process and messing with LOAD_PATH. Autoswitching occurs when the BUNDLED_WITH in the Gemfile.lock
50+
# is a different version than the loaded version of bundler. This can happen in development when
51+
# switching between ruby versions.
52+
Bundler.setup
4853
end
4954

5055
# This returns its best estimate of the Resident Set Size in bytes.

0 commit comments

Comments
 (0)