How to upgrade from ruby 2.2.3 to ruby 2.3.0

Jeramae Bohol picture Jeramae Bohol · May 13, 2016 · Viewed 31.5k times · Source

My current Ruby version is 2.2.3 and I want to upgrade it to 2.3.0.

I use rbenv using this guide: gorails.com/setup/ubuntu/16.04

How do I upgrade my Ruby version? And when I upgrade, does it affect anything that I need to be aware of?

Answer

Michael Gaskill picture Michael Gaskill · May 13, 2016

This answer had been written to address the original question, which did not specify rbenv as a preferred approach. Although the question changed after this answer was written, the answer has been retained to help users that may be using RVM to upgrade/manage their Ruby installations.

See the rbenv answer for details on using rbenv for the same purpose.


Use RVM or another Ruby version manager. This is far superior to installing a new system Ruby in most cases.

If you're upgrading your system Ruby, you have a number of things to keep in mind:

  • what other dependencies are there on that Ruby version?
  • are all of the gems going to be available after upgrade?
  • which applications are using the existing Ruby version and what can/will break after upgrade?
  • are there any other users using the existing Ruby that need to be aware of (and prepare for) the change?

With a Ruby version manager, you eliminate most of these concerns. You can run multiple Ruby versions on the same machine, which gives you the ability to test backward and forward compatibility. It also lets you experiment with the newer Ruby versions to make sure that they're fully stable for use.

You can install RVM using this method from any bash shell:

\curl -sSL https://get.rvm.io | bash -s stable

or update it to the most recent stable version by using:

rvm get stable

Once RVM is installed (or updated), you can install any Ruby version you choose, by doing the following:

rvm install 2.3.0

or upgrade from one version to another:

rvm upgrade 2.2.3 2.3.0

You can see which Ruby versions are installed by using this:

rvm list

You can also check to see which versions of Ruby that you can install on RVM by using this command:

rvm list known

Switch to a specific installed Ruby version by using the use command:

rvm use 2.3.0

and then switch back to an older version when you need to:

rvm use 2.2.3

Check out the RVM documentation for more features. You'll be surprised at how useful RVM actually is. There's a whole lot more to it than just what's shown here.