Skip to content

Commit 111bd11

Browse files
Load hax.rb before anything when BUNDLER_IGNORE_DEFAULT_GEM set
1 parent 73b9498 commit 111bd11

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bundler/spec/support/helpers.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def bundle(cmd, options = {}, &block)
116116
end
117117
end.join
118118

119-
ruby_cmd = build_ruby_cmd({ load_path: load_path, requires: requires })
119+
ruby_cmd = build_ruby_cmd({ load_path: load_path, requires: requires, env: env })
120120
cmd = "#{ruby_cmd} #{bundle_bin} #{cmd}#{args}"
121121
sys_exec(cmd, { env: env, dir: dir, raise_on_error: raise_on_error }, &block)
122122
end
@@ -147,7 +147,13 @@ def build_ruby_cmd(options = {})
147147
lib_option = libs ? "-I#{libs.join(File::PATH_SEPARATOR)}" : []
148148

149149
requires = options.delete(:requires) || []
150-
requires << "#{Path.spec_dir}/support/hax.rb"
150+
151+
hax_path = "#{Path.spec_dir}/support/hax.rb"
152+
153+
# For specs that need to ignore the default Bundler gem, load hax before
154+
# anything else since other stuff may actually load bundler and not skip
155+
# the default version
156+
options[:env]&.include?("BUNDLER_IGNORE_DEFAULT_GEM") ? requires.prepend(hax_path) : requires.append(hax_path)
151157
require_option = requires.map {|r| "-r#{r}" }
152158

153159
[Gem.ruby, *lib_option, *require_option].compact.join(" ")

0 commit comments

Comments
 (0)