Image for post
Image for post

A Tale of Two Rubies, Part I

In a typical ruby shop, there’s a strong likelihood that you’ll come across RVM or rbenv for managing ruby versions. These tools are useful to juggle different projects, where different versions are required.

The Tutorial

We’ll create two pretend projects that mimic a potential real-world use cases:

  • Empower – Sinatra, Ruby 2.3

RVM Install

The first step is setting up RVM for the current user:

Rubies and Gems

Here we can install some ruby and gems for our projects:

Project: Fearless

This is a pretend web project using a recent version of Ruby on Rails 5 on Ruby 2.4:

Project: Empower

This is a pretend web microservice project using earlier version of Sinatra 1.4 running on Ruby 2.3:

Testing Project Rubies

With steps above, you can now easily switch between ruby versions and gemsets by simply switching into those directories. RVM will auto-configure the environment for you:

$ cd ${HOME}/projects$ rvm use 2.3.6
$ ruby -v
ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-linux]
$ gem env home
/home/vagrant/.rvm/gems/ruby-2.3.6
$ cd fearless
$ ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
$ gem env home
/home/vagrant/.rvm/gems/ruby-2.4.3@fearless20

Conclusion

I hope this introduction was useful regarding managing ruby and gemsets. Next article, I will cover Rbenv and why gemsets are not used, and even discouraged.

Written by

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, Kubernetes, CNI, IAC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store