Skip to content

Commit

Permalink
[rubygems/rubygems] Load hax.rb before anything when `BUNDLER_IGNORE_…
Browse files Browse the repository at this point in the history
…DEFAULT_GEM` set

rubygems/rubygems@111bd11c36
  • Loading branch information
deivid-rodriguez authored and hsbt committed Dec 13, 2023
1 parent 8d1a203 commit 7d5d2ee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/bundler/support/helpers.rb
Expand Up @@ -116,7 +116,7 @@ def bundle(cmd, options = {}, &block)
end
end.join

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

requires = options.delete(:requires) || []
requires << "#{Path.spec_dir}/support/hax.rb"

hax_path = "#{Path.spec_dir}/support/hax.rb"

# For specs that need to ignore the default Bundler gem, load hax before
# anything else since other stuff may actually load bundler and not skip
# the default version
options[:env]&.include?("BUNDLER_IGNORE_DEFAULT_GEM") ? requires.prepend(hax_path) : requires.append(hax_path)
require_option = requires.map {|r| "-r#{r}" }

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

0 comments on commit 7d5d2ee

Please sign in to comment.