diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-11-16 20:19:13 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-11-16 20:19:13 +0900 |
commit | f3bda8987ecf78aa260e697232876b35f83b67c3 (patch) | |
tree | 4031690093d2cb9ca6f0b25e723771bacf76e872 /lib/rubygems/installer.rb | |
parent | 84fdaaab4605020103c77df7665556de0a02dad2 (diff) |
Merge the master branch of rubygems repo
Picked from https://github.com/rubygems/rubygems/commit/4b498709a015a94e14a3852a1841a7a3e669133d
Diffstat (limited to 'lib/rubygems/installer.rb')
-rw-r--r-- | lib/rubygems/installer.rb | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index cf5ed7b502..dd6dd06eef 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -5,7 +5,6 @@ # See LICENSE.txt for permissions. #++ -require_relative 'command' require_relative 'installer_uninstaller_utils' require_relative 'exceptions' require_relative 'deprecate' @@ -71,6 +70,23 @@ class Gem::Installer @install_lock = Thread::Mutex.new class << self + # + # Changes in rubygems to lazily loading `rubygems/command` (in order to + # lazily load `optparse` as a side effect) affect bundler's custom installer + # which uses `Gem::Command` without requiring it (up until bundler 2.2.29). + # This hook is to compensate for that missing require. + # + # TODO: Remove when rubygems no longer supports running on bundler older + # than 2.2.29. + + def inherited(klass) + if klass.name == "Bundler::RubyGemsGemInstaller" + require "rubygems/command" + end + + super(klass) + end + ## # True if we've warned about PATH not including Gem.bindir @@ -676,7 +692,7 @@ class Gem::Installer @development = options[:development] @build_root = options[:build_root] - @build_args = options[:build_args] || Gem::Command.build_args + @build_args = options[:build_args] unless @build_root.nil? @bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, '')) @@ -832,7 +848,7 @@ TEXT # configure scripts and rakefiles or mkrf_conf files. def build_extensions - builder = Gem::Ext::Builder.new spec, @build_args + builder = Gem::Ext::Builder.new spec, build_args builder.build_extensions end @@ -919,7 +935,7 @@ TEXT # extensions. def write_build_info_file - return if @build_args.empty? + return if build_args.empty? build_info_dir = File.join gem_home, 'build_info' @@ -929,7 +945,7 @@ TEXT build_info_file = File.join build_info_dir, "#{spec.full_name}.info" File.open build_info_file, 'w' do |io| - @build_args.each do |arg| + build_args.each do |arg| io.puts arg end end @@ -954,4 +970,13 @@ TEXT raise Gem::FilePermissionError.new(dir) unless File.writable? dir end + + private + + def build_args + @build_args ||= begin + require_relative "command" + Gem::Command.build_args + end + end end |