aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems
diff options
context:
space:
mode:
authorKyle Stevens <kstevens715@gmail.com>2023-10-14 07:32:07 -0400
committergit <svn-admin@ruby-lang.org>2023-10-18 10:17:58 +0000
commitef3f9f1a685effb51543d1f08831692fa68863a2 (patch)
tree67ab739ed3b80c3ba8ef1fa08c9d6ae99f8feb82 /lib/rubygems
parent8e6a2511387f47894407ea92494c0f5d3cdb51b8 (diff)
downloadruby-ef3f9f1a685effb51543d1f08831692fa68863a2.tar.gz
[rubygems/rubygems] Allow uninstalling multiple versions of same gem
Currently, you can install multiple versions of the same gem just fine: ``` $ gem install simplecov:0.19.0 simplecov:0.22.0 Fetching simplecov-0.19.0.gem Successfully installed simplecov-0.19.0 Parsing documentation for simplecov-0.19.0 Installing ri documentation for simplecov-0.19.0 Done installing documentation for simplecov after 0 seconds Fetching simplecov-0.22.0.gem Successfully installed simplecov-0.22.0 Parsing documentation for simplecov-0.22.0 Installing ri documentation for simplecov-0.22.0 Done installing documentation for simplecov after 0 seconds 2 gems installed ``` But to uninstall both of them, you need to run the equivalent uninstall command twice: ``` ~$ gem uninstall simplecov:0.19.0 simplecov:0.22.0 Successfully uninstalled simplecov-0.22.0 ~$ gem uninstall simplecov:0.19.0 simplecov:0.22.0 Gem 'simplecov' is not installed Successfully uninstalled simplecov-0.19.0 ``` This resolves that problem by using the gem's full name (which includes the version) when tracking which ones have already been uninstalled so when it gets to the second version listed it doesn't think it was already uninstalled. https://github.com/rubygems/rubygems/commit/d96101b753
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/commands/uninstall_command.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index c66bbe42e1..7f6d5a4bb7 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -168,10 +168,10 @@ that is a dependency of an existing gem. You can use the
gems_to_uninstall = {}
deps.each do |dep|
- next if gems_to_uninstall[dep.name]
- gems_to_uninstall[dep.name] = true
-
- unless original_gem_version[dep.name] == Gem::Requirement.default
+ if original_gem_version[dep.name] == Gem::Requirement.default
+ next if gems_to_uninstall[dep.name]
+ gems_to_uninstall[dep.name] = true
+ else
options[:version] = dep.version
end