The Basics of Managing Multiple Ruby Versions

Every project can have it’s own Gem dependencies and version requirements making switching between Ruby projects difficult especially for visual designers and beginners. Ruby management tools such as RVM and rbenv help you install and manage multiple Ruby environments. I’m a Mac guy and most recently I’ve been using rbenv so this post focuses on OSX and rbenv.

Mac OSX ships with Ruby installed by default and it only allows for one installation at a time. So any local Ruby projects will run using that version.

osx-ruby

When you install rbenv, it’s placed in your user home directory and any Ruby versions are then installed in a subdirectory named “versions”.

rbenv-ruby

When you need to install another version of Ruby all you need to do is use the command below:


# list all available versions:
$ rbenv install -l

# install a Ruby version:
$ rbenv install 2.0.0-p247

And in the root directory of your project set the local Ruby version that you want that project to use:


$ rbenv local 2.0.0-p247

This simply creates a filed named “.ruby-version” in the project with the version number that corresponds to your preference “2.0.0-p247 “. (And fortunately RVM uses the same file name making switching between the two tools easier.) So anytime you run that Ruby project it will use the local version of Ruby. And any gems installed will be installed within the rbenv “versions” subdirectory rather than in the OSX “Gems” subdirectory.

For a full list of commands visit the rbenv GitHub repo.

rbenv-ruby-version

Leave a Reply

Your email address will not be published. Required fields are marked *