breaking into the unknown…

rvmrc autoload rvm gemset

Leave a comment

You may be working on different projects and each one using different gemset with rvm. You generally follow below steps on terminal to set correct gemset for your project.

$ rvm list #will list all the installed rubies, only one in my case
rvm rubies
=* ruby-1.9.3-p194 [ i686 ]
$ rvm use ruby-1.9.3-p194 #set the ruby version

$ rvm gemset create thirdpillar #create a gemset if not already there

$ rvm gemset list # it list all the gemset within the selected ruby
gemsets for ruby-1.9.3-p194 (found in /home/arun/.rvm/gems/ruby-1.9.3-p194)

$ rvm gemset use thirdpillar # It will sete thirdpillar gemset for my project say myproject

what if I want to skip typing these every time, and want to automatically load the correct rvm and gemset for my project whenever I cd to myproject on the terminal. This can be done by adding .rvmrc file to your project folder.  and adding just one line to it as below

rvm your_complete_gemset_name

Example: for the ruby and gemset we have selected above , the line will be

rvm ruby-1.9.3-p194@thirdpillar # If you have any doubt about the complete name of gemset to use,  go to .rvm folder -> then click gems folder, there you will find one folder for every gemset you have created, just copy the name of folder you want to use.

Now, when you go to terminal and cd to your project, the correct ruby and gemset will be automatically loaded

$ cd myproject

myproject$ #thus you moved to myproject folder which will load the gemset automatically

NOTE : do not commit .rvmrc to git as, other your other team mate may have created gemset with different name. So better to add .rvmrc to .gitignore file, so that it should not be commited by even mistake


Author: arunyadav4u

over 7 years experience in web development with Ruby on Rails.Involved in all stage of development lifecycle : requirement gathering, planing, coding, deployment & Knowledge transfer. I can adept to any situation, mixup very easily with people & can be a great friend.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s