aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/uninstaller.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-30 13:01:35 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-30 13:01:35 +0000
commit8da8d4b043c37b53a69803c71ff36b478d4776d0 (patch)
tree7c8cec15645e74f19c88e4eb5b210b96174c7d03 /lib/rubygems/uninstaller.rb
parentc5cb386eba6d9a2d9a8e6ffa8c30137d0c4660c1 (diff)
downloadruby-8da8d4b043c37b53a69803c71ff36b478d4776d0.tar.gz
Merge RubyGems 3.0.0.beta1.
* It drop to support < Ruby 2.2 * Cleanup deprecated methods and classes. * Mark obsoleted methods to deprecate. * and other enhancements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/uninstaller.rb')
-rw-r--r--lib/rubygems/uninstaller.rb35
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index 89f47a45fe..3059099373 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -213,8 +213,8 @@ class Gem::Uninstaller
exe_file = File.join bin_dir, exe_name
- FileUtils.rm_f exe_file
- FileUtils.rm_f "#{exe_file}.bat"
+ safe_delete { FileUtils.rm exe_file }
+ safe_delete { FileUtils.rm "#{exe_file}.bat" }
end
else
say "Executables and scripts will remain installed."
@@ -250,26 +250,26 @@ class Gem::Uninstaller
raise Gem::FilePermissionError, spec.base_dir unless
File.writable?(spec.base_dir)
- FileUtils.rm_rf spec.full_gem_path
- FileUtils.rm_rf spec.extension_dir
+ safe_delete { FileUtils.rm_r spec.full_gem_path }
+ safe_delete { FileUtils.rm_r spec.extension_dir }
old_platform_name = spec.original_name
- gemspec = spec.spec_file
-
- unless File.exist? gemspec then
- gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
- end
-
- FileUtils.rm_rf gemspec
gem = spec.cache_file
gem = File.join(spec.cache_dir, "#{old_platform_name}.gem") unless
File.exist? gem
- FileUtils.rm_rf gem
+ safe_delete { FileUtils.rm_r gem }
Gem::RDoc.new(spec).remove
+ gemspec = spec.spec_file
+
+ unless File.exist? gemspec then
+ gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
+ end
+
+ safe_delete { FileUtils.rm_r gemspec }
say "Successfully uninstalled #{spec.full_name}"
Gem::Specification.reset
@@ -343,4 +343,15 @@ class Gem::Uninstaller
filename
end
end
+
+ def safe_delete(&block)
+ block.call
+ rescue Errno::ENOENT
+ nil
+ rescue Errno::EPERM
+ e = Gem::UninstallError.new
+ e.spec = @spec
+
+ raise e
+ end
end