Fix issue when plugin stubs would sometimes not be properly removed by gem uninstall
#7631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was the end-user or developer problem that led to this PR?
gem uninstall <gem> --install-dir <dir>
will fail to remove plugin stubs if the version being removed is also installed globally.See for example how, without
rubygems-server
installed globally, plugin is properly removed from--install-dir
:However, if I have
rubygems-server
installed in my standard GEM_HOME,gem uninstall
will fail to clean it up from--install-dir
:What is your fix for the problem, implemented in this PR?
In order to keep plugins up to date,
gem uninstall
does the following:The second check, however, was checking globally installed gems instead of gems in
--install-dir
.The solution is to make sure that check uses
--install-dir
rather than the default GEM_HOME.To implement it, I extracted the functionality that deals with the list of know specifications to a separate
SpecificationRecord
class that can take a custom directory (--install-dir
in this case).Make sure the following tasks are checked