Skip to content

Commit

Permalink
Fix problem when downgrading rubygems
Browse files Browse the repository at this point in the history
Take the following scenario:

* You have a rubygems version with the new plugins system.
* You run `gem install yard`, so that `<gem_home>/plugins/yard_plugin.rb` is generared.
* You downgrade rubygems to a version with the old plugin system, say, 3.1.2.
* You uninstall yard.
* You upgrade rubygems again.

In this case, the final upgrade will fail because rubygems will try to
require a `yard` rubygems plugin to points to a file that does not exist
because the `yard` gem is not installed.

This change fixes that problem.
  • Loading branch information
deivid-rodriguez committed Jan 31, 2020
1 parent 902a30f commit 8567139
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/rubygems/commands/update_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ def install_rubygems(version) # :nodoc:
Dir.chdir update_dir do
say "Installing RubyGems #{version}"

installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args
if Gem::Version.new(version) < Gem::Version.new("3.2.a")
require "tmpdir"
tmpdir = Dir.mktmpdir
FileUtils.mv Gem.plugins_dir, tmpdir
installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args
FileUtils.mv File.join(tmpdir, "plugins"), Gem.plugins_dir unless installed
else
installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args
end

say "RubyGems system software updated" if installed
end
end
Expand Down

0 comments on commit 8567139

Please sign in to comment.