Joshua Spence Joshua Spence - 6 months ago 26
Ruby Question

Difference between `update_rubygems` and `gem update --system`

What is the difference between this command:

gem update --system


And these commands:

gem install rubygems-update
update_rubygems
gem update --system


I would've assumed that the former would be all that is required in order to update to the latest version of RubyGems, but I have found many references (including http://stackoverflow.com/a/13626200/1369417) which recommend the latter.

Answer

gem install rubygems-update; update_rubygems was needed in some old versions of rubygems, but gem update --system is all that's needed for the foreseeable future.

rubygems 1.1 and 1.2 had bugs that prevented gem upgrade --system from working the first time, so you had to use those first two commands to upgrade at all. There would be no reason to run gem upgrade --system immediately thereafter, because rubygems would already be upgraded, but doing so would demonstrate that you would be able to run that command in the future.

Versions of rubygems before 1.5.2 did not accept a version argument following gem upgrade --system, so you had to use the first two commands you give to install an arbitrary version of rubygems. You wouldn't want to run gem update --system immediately thereafter; it would undo what you'd just done.

More here: https://github.com/rubygems/rubygems/blob/master/UPGRADING.rdoc

I am pleased to have just discovered that these complications won't be necessary in the future: rubygems must have committed to gem update --system working, because while Ruby 2.2 had an update_rubygems executable, Ruby 2.3 does not.