Managing my local rubies

Some years ago I started managing my local rubies with RVM, but during the past 2 years I switched to Rbenv and right now I’m switching back to my old friend RVM.

Here’s my basic workflow using RVM:

When I start on some new/legacy ruby project, the first thing I need to decide (or to discover) is the Ruby version I should
to use there. Then, one of the first steps is to take a look at my current versions available and check if I already have
what I need to start working:

1
2
3
4
5
6
7
8
9
10
$ rvm list
rvm rubies
ruby-1.9.3-p194 [ x86_64 ]
=> ruby-2.1.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default

If I need to use the version 2.1.3, for example, and don’t have it installed yet, then:

1
$ rvm install 2.1.3

Normally it demands some time to be complete.

With the right Ruby version available to go then it’s time to create a specific Gemset for my project:

1
$ rvm gemset create myProj

Gemset is cool because they keep our rubygems from a specific project isolated from the other projects running on your machine.

Next, we need to define the ruby version + gemset we will use on the project:

1
2
$ rvm use 2.1.3
$ rvm gemset use myProj

or a shortcut to do it is:

1
$ rvm use 2.1.3@myProj

One good and straightforward practice is to create the default RVM files of your project defining the ruby version and gemset to be use there by default:

1
$ echo 'rvm use ruby-2.1.3@myProj' > .rvmrc && rvm rvmrc to ruby-version

So every time when you access the project RVM will detect and use the proper configurations.

If you forget to create it, you’ll need to specify whenever you access the project folder using again the commands “rvm use” and “rvm gemset use” and as you can imagine it’s not fun.

So, if you are still not using RVM (or maybe Rbenv) to manage your locals rubies and gems, then probably your are wasting a
lot of time and energy fighting against the headaches of different gems/ruby versions between several projects and
I hope you can use this small guide to improving your development process.

avatar

Tailor Fontela

Software Developer. Full-time apprenticeship.