Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow explicitly uninstalling multiple versions of same gem #7063

Merged
merged 1 commit into from Oct 18, 2023

Conversation

kstevens715
Copy link
Contributor

@kstevens715 kstevens715 commented Oct 14, 2023

What was the end-user or developer problem that led to this PR?

As described in #6979, 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

What is your fix for the problem, implemented in this PR?

When just a gem name is specified without a version, there's code so the uninstall only happens once for a gem when there's multiple versions installed which makes sense because the next step lets the user choose which specific version or if they want to uninstall all versions. This PR bypasses the skip logic if a specific gem version was given so that all can be uninstalled.

Make sure the following tasks are checked

@welcome
Copy link

welcome bot commented Oct 14, 2023

Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.

For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide

@kstevens715 kstevens715 force-pushed the gem-uninstall branch 4 times, most recently from 31df021 to b73ea9d Compare October 14, 2023 22:30
@kstevens715 kstevens715 marked this pull request as ready for review October 14, 2023 22:34
@kstevens715 kstevens715 changed the title Allow uninstalling multiple versions of same gem Allow explicitly uninstalling multiple versions of same gem Oct 14, 2023
@deivid-rodriguez
Copy link
Member

Thanks so much, just approved CI to run for you, let's see how it goes!

Copy link
Member

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

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.
@deivid-rodriguez deivid-rodriguez merged commit a3696cb into rubygems:master Oct 18, 2023
83 checks passed
deivid-rodriguez added a commit that referenced this pull request Nov 8, 2023
Allow explicitly uninstalling multiple versions of same gem

(cherry picked from commit a3696cb)
deivid-rodriguez added a commit that referenced this pull request Nov 8, 2023
Allow explicitly uninstalling multiple versions of same gem

(cherry picked from commit a3696cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants