diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-03-24 07:39:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-24 15:39:24 +0900 |
commit | 96064e6f1ce100a37680dc8f9509f06b3350e9c8 (patch) | |
tree | 798b59f015cb82ee3cd0427f80584032175829ba /lib/rubygems/installer.rb | |
parent | 930b012ad96bfb0bd12446b89407120744ef92eb (diff) | |
download | ruby-96064e6f1ce100a37680dc8f9509f06b3350e9c8.tar.gz |
Sync rubygems with current master (#2889)
Diffstat (limited to 'lib/rubygems/installer.rb')
-rw-r--r-- | lib/rubygems/installer.rb | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 2ba92482cc..abb7048b00 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -47,11 +47,6 @@ class Gem::Installer include Gem::InstallerUninstallerUtils ## - # Filename of the gem being installed. - - attr_reader :gem - - ## # The directory a gem's executables will be installed into attr_reader :bin_dir @@ -487,13 +482,7 @@ class Gem::Installer def generate_bin # :nodoc: return if spec.executables.nil? or spec.executables.empty? - begin - Dir.mkdir @bin_dir, *[options[:dir_mode] && 0755].compact - rescue SystemCallError - raise unless File.directory? @bin_dir - end - - raise Gem::FilePermissionError.new(@bin_dir) unless File.writable? @bin_dir + ensure_writable_dir @bin_dir spec.executables.each do |filename| filename.tap(&Gem::UNTAINT) @@ -523,10 +512,12 @@ class Gem::Installer latest = Gem::Specification.latest_spec_for(spec.name) return if latest && latest.version > spec.version + ensure_writable_dir @plugins_dir + if spec.plugins.empty? - remove_plugins_for(spec) + remove_plugins_for(spec, @plugins_dir) else - regenerate_plugins_for(spec) + regenerate_plugins_for(spec, @plugins_dir) end end @@ -690,6 +681,7 @@ class Gem::Installer @force = options[:force] @install_dir = options[:install_dir] @gem_home = options[:install_dir] || Gem.dir + @plugins_dir = Gem.plugindir(@gem_home) @ignore_dependencies = options[:ignore_dependencies] @format_executable = options[:format_executable] @wrappers = options[:wrappers] @@ -890,6 +882,13 @@ TEXT end ## + # Filename of the gem being installed. + + def gem + @package.gem.path + end + + ## # Performs various checks before installing the gem such as the install # repository is writable and its directories exist, required Ruby and # rubygems versions are met and that dependencies are installed. @@ -953,4 +952,14 @@ TEXT @package.copy_to cache_file end + def ensure_writable_dir(dir) # :nodoc: + begin + Dir.mkdir dir, *[options[:dir_mode] && 0755].compact + rescue SystemCallError + raise unless File.directory? dir + end + + raise Gem::FilePermissionError.new(dir) unless File.writable? dir + end + end |