Ruby-on-rails – How to install Ruby gems when using RVM

rubyruby-on-railsruby-on-rails-3rubygemsrvm

I set up RVM and used it to install Ruby and a few other libraries. As I was going through various tutorials and set-ups of other technologies like Rails, I began getting confused about what I should do via RVM and what I should just do as the tutorials suggest.

One example is the RubyGems tutorial here:
http://rubygems.org/pages/download

Should I download that tar file they are talking about? Seems unnecessary since that is what I thought RVM was for. Do I even need RubyGems? What is that for really?

Also, how do I actually get Rails? Is there a precise RVM command to actually download and install Rails?

Best Answer

It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.

Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.

With RVM: ruby related stuff is intercepted by rvm so that ruby, gems, and ruby related binares are "installed" into ~/.rvm dir in a nice, clean, organized way. RVM sits between ruby, gems, and related binaries and the operating system. It provides a way to have multiple ruby environments (with different gems and binaries) on the same machine.

So, no matter whether you have rvm installed or not, you should be able to run the commands almost exactly(*) as they appear in any tutorials out there on the web. In other words, you can sort of "forget" that RVM is installed; the ruby ecosystem should work just as if it wasn't installed.

So, yep, you're gonna have to run gem install rails, etc.

Hope that helps clear the confusion.

(*) There are some small differences. For example: you shouldn't run commands as sudo when RVM is installed.