There are two "Ruby version managers" out there, which you can choose from:
These were built for keeping multiple versions of Ruby on the same system. Once you've installed them, and installed your own Ruby version, you won't mess with your system's Ruby and its Gems, which is the greatest benefit.
Which one should I choose?
Both do the same thing, but they follow different philosophies;
rbenv tries to be more lightweight with optional plugins, while is RVM more full-featured when it comes to installing Rubies and keeping different Gemsets. So the choice is up to you.
I'd personally recommend
rbenv for its simplicity. I've been using it since years and it has always worked well. Previously I would have recommended RVM (and an earlier version of this answer actually mentioned it), but I feel it's harder to get into.
How do I install them?
If you choose
- Follow the installation instructions
rbenv install x.x.x where
x.x.x is the version (use
rbenv install --list to see which ones are available
rbenv global x.x.x to change your global Ruby version
If you choose RVM:
- Use the secure installation method
- Read the installation instructions — you probably want the single-user configuration
rvm list known to list available Rubies and then run
rvm install x.x.x to install a specific version.
rvm use x.x.x --default to change your default Ruby