From 28356c2870e1a9606cff998e2b888bd5bd517b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 8 Nov 2023 13:30:41 +0100 Subject: [PATCH] [rubygems/rubygems] Explicitly pass install-dir when installing system gems in Bundler specs We want to avoid any "user home" fallbacks, since that won't work with Bundler. So if there's a permissions issue during specs, it's best to raise immediately. https://github.com/rubygems/rubygems/commit/767a3e7533 --- spec/bundler/support/helpers.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 73621685ba..f4dd6fc89b 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -293,29 +293,29 @@ module Spec def system_gems(*gems) gems = gems.flatten options = gems.last.is_a?(Hash) ? gems.pop : {} - path = options.fetch(:path, system_gem_path) + install_dir = options.fetch(:path, system_gem_path) default = options.fetch(:default, false) - with_gem_path_as(path) do + with_gem_path_as(install_dir) do gem_repo = options.fetch(:gem_repo, gem_repo1) gems.each do |g| gem_name = g.to_s if gem_name.start_with?("bundler") version = gem_name.match(/\Abundler-(?.*)\z/)[:version] if gem_name != "bundler" - with_built_bundler(version) {|gem_path| install_gem(gem_path, default) } + with_built_bundler(version) {|gem_path| install_gem(gem_path, install_dir, default) } elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name) - install_gem(gem_name, default) + install_gem(gem_name, install_dir, default) else - install_gem("#{gem_repo}/gems/#{gem_name}.gem", default) + install_gem("#{gem_repo}/gems/#{gem_name}.gem", install_dir, default) end end end end - def install_gem(path, default = false) + def install_gem(path, install_dir, default = false) raise "OMG `#{path}` does not exist!" unless File.exist?(path) - args = "--no-document --ignore-dependencies --verbose --local" - args += " --default --install-dir #{system_gem_path}" if default + args = "--no-document --ignore-dependencies --verbose --local --install-dir #{install_dir}" + args += " --default" if default gem_command "install #{args} '#{path}'" end