Posted over 5 years ago. Visible to the public.

How to update RubyGems binary for all installed rubies

To update your Rubygems to the latest available version, type the following:

Copy
gem update --system

Note that you have a separate Rubygems installation for each Ruby version in your RVM or rbenv setup. Updating one does not update the others.

Ruby 1.8.7

If you are using Ruby 1.8.7 you cannot use the latest version of Rubygems. Type the following to get the latest version that is compatible with 1.8.7:

Copy
gem update --system 1.8.30

Updating RubyGems for all installed Ruby versions

Because of occasional security issues in RubyGems binaries, you should keep them updated across all Rubies on your machines. [1]

Here is how to do that in batch.
Afterwards, list your installed versions to confirm it worked.

rbenv

Here is a one-line bash script that will update all, and fall back to 1.8.30 for Ruby 1.8.7:

Copy
for i in `rbenv versions --bare`; do rbenv shell $i; echo $i; if [ ${i:0:4} = 1.8. ]; then gem update --system 1.8.30; else gem update --system; fi; done

RVM

Use RVM's rvm all do:

Copy
rvm all do gem update --system

As mentioned above, the latest version will not work on Ruby 1.8.7. Manually switch to all such versions and use the compatible version like this:

Copy
rvm use 1.8.7 rvm rubygems latest-1.8 --force

[1] Note that Ruby 1.8.7 can not use the latest version or it would throw a NoMethodError: undefined method source_index for Gem:Module. We use the latest compatible version instead.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
over 4 years ago
by Tobias Kraze
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more