Project Ramon

A learning journey from a Ruby noob perspective

Gemests: Building Buckets of Bling

gemset_header_img

Today we’ll be going over how to setup a project specific rvm gemset for our Rails projects.

The link above will take you to the RVM official site, its a solid place to look as this post will be using the instructions there. Lets get started.

Step 1: Make sure to have your preferred Ruby Version in use

We can do this by typing ruby -v in our terminal. Your output will look something like so:

gemset_img1

If your output isn’t what you expected your Ruby version to be, you can first ensure that you don’t have the Ruby version already installed by typing which ruby which will show a display similar to this:

gemset_img2

Followed by typing rvm list to see which version(s) of Ruby are installed currently. Your output will look something like this:

gemset_img3

Lets say for example that we wanted to add an additional version of Ruby to our RVM. We could do that by typing rvm install 1.9.3, obviously the version numbers can be personalized for your needs. I’m installing 1.9.3 because for demonstrative purposes as I already have 2.1.0 installed.

Here’s what you’re terminal will look like as it begins making the installation:

gemset_img4

Once we have our desired version of Ruby installed, we can make RVM select this version by typing rvm 1.9.3 changing only the versioning numbers to suit your needs.

Step: 2 Create a Gemset

This next step is short and sweet. To have the terminal autoload a gemset depending on which project we’re in. We can change directory (i.e. typing cd project_folder) into our desired project, and then type rvm gemset create gemset_name. To date, I’ve always named my gemsets the same as my project names, but you can name your gemset however you’d prefer.

To use this gemset and tie it to a specific version of Ruby, we just type rvm 2.1.0@gemset_name and pretso! Our project specific gemset is created!

Step: 3 Install Gems

Now we just have to install the version of Rails we’re looking to use by typing gem install rails -v 3.2.16 or gem install rails to get the latest stable version of the framework.

Next it would be a good idea to install the bundler gem so we can add the rest of our gems.
gem install bunlder. This will create a Gemfile in our project’s root, and from there we can just add the gems we’d like and finish off by typing bundle install.

This is something I found myself spending time on today as I dealt with getting ready for my next project. If you would like to add any instructions to this short walkthrough of creating gemsets in RVM, feel free to leave a comment.

Stay tuned…

Advertisements

Categories: Ruby on rails

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s