Skip to content

Instantly share code, notes, and snippets.

@larsthegeek
Created November 7, 2012 01:38
Show Gist options
  • Save larsthegeek/4029012 to your computer and use it in GitHub Desktop.
Save larsthegeek/4029012 to your computer and use it in GitHub Desktop.
Update RubyGems to a specific version (for legacy system installs)
How to update RubyGems to a specific version
RubyGems can update itself to the latest version:
gem update --system
However, you always get the newest version. This may be a problem if you’re trying to replicate a known-good environment: for example, the output format of `gem list` in RubyGems 1.3.7 breaks Chef 0.8.16 in certain circumstances. 1.3.6 is fine.
Here’s how to update to a specific version—in this case, 1.3.6:
gem install -v 1.3.6 rubygems-update && \
ruby `gem env gemdir`/gems/rubygems-update-1.3.6/setup.rb
It’s also possible to revert RubyGems to an older version using this method.
(And if you’re wondering why I don’t just install the version I want, well, Ruby Enterprise Edition comes with RubyGems already. I’d prefer to update that than to install another copy.)
@TSMMark
Copy link

TSMMark commented Dec 19, 2018

For the record, these days you can simply supply the version to gem update --system

gem update --system 2.7.8

@Nakilon
Copy link

Nakilon commented May 11, 2025

For Ruby 2.7:

gem update --system 3.4.22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment