aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/commands/uninstall_command.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-02 11:48:18 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-02 11:48:18 +0000
commitf28be7e02d113bd26c33cb94e65004055576c065 (patch)
tree48b87f5a2b647e1207bae5e29f40d6d5b526978d /lib/rubygems/commands/uninstall_command.rb
parent537024433720d7c54cba9bab4596638f59fbadc9 (diff)
downloadruby-f28be7e02d113bd26c33cb94e65004055576c065.tar.gz
Merge rubygems/rubygems from upstream.
The current master branch is https://github.com/rubygems/rubygems/commit/97b264f0fa248c864b6ee9a23d3ff1cdd217dddb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/uninstall_command.rb')
-rw-r--r--lib/rubygems/commands/uninstall_command.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 698ff4b555..68e048c010 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -148,10 +148,13 @@ that is a dependency of an existing gem. You can use the
def uninstall_specific
deplist = Gem::DependencyList.new
+ original_gem_version = {}
get_all_gem_names_and_versions.each do |name, version|
- requirement = Array(version || options[:version])
- gem_specs = Gem::Specification.find_all_by_name(name, *requirement)
+ original_gem_version[name] = version || options[:version]
+
+ gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name])
+
say("Gem '#{name}' is not installed") if gem_specs.empty?
gem_specs.each do |spec|
deplist.add spec
@@ -160,16 +163,23 @@ that is a dependency of an existing gem. You can use the
deps = deplist.strongly_connected_components.flatten.reverse
+ gems_to_uninstall = {}
+
deps.each do |dep|
- options[:version] = dep.version
- uninstall_gem(dep.name)
+ unless gems_to_uninstall[dep.name]
+ gems_to_uninstall[dep.name] = true
+
+ unless original_gem_version[dep.name] == Gem::Requirement.default
+ options[:version] = dep.version
+ end
+
+ uninstall_gem(dep.name)
+ end
end
end
def uninstall_gem(gem_name)
uninstall(gem_name)
- rescue Gem::InstallError
- nil
rescue Gem::GemNotInHomeException => e
spec = e.spec
alert("In order to remove #{spec.name}, please execute:\n" +