- Read Tutorial
- Watch Guide Video
In this guide, we are going to install a very important tool for Ruby and Rails development, which is the Ruby Version Manager (RVM). To check if you already have RVM on your computer type rvm list
into your terminal. If you get an error message it means you do not have RVM installed.
How to Install RVM
To install, go to their website at rvm.io.
Paste this code into your terminal:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
The first line starts the GPG, so we can have a secure connection, while the second line of code uses a curl command. Curl gives us the ability to make an outside communication request. We are talking to another server and sending a request (to "rvm.io") to return a stable version of the code.
Now type rvm list
again. You will see a list of ruby versions on your computer.
Importance of RVM
If you're working on a Mac computer, you will already have Ruby installed on your system. To check the version, simply type ruby -v
.
However, this is not the best way to manage your Ruby versions. If you notice, I have many versions of Ruby because I have applications I have been working on that are up to five years old. These different applications have various ruby language versions and I need to be able to switch back and forth between those versions while working on the different applications. Using RVM will allow you to properly manage the version of ruby you are using in your different applications.
How to Install a Specific Version of Ruby
Go to ruby-lang.org, and here, you'll see all the different announcements about the Ruby programming language. At the time of making this video, Ruby had released its latest version, which is 2.4.0, but I don't have it in my system.
To install it, the command is rvm install 2.4.0
Another advantage of RVM is that it assists you in installing the specific version of Ruby you want. If you had to do this manually, it could be a tedious process. RVM also makes it easy for you to switch between different versions of ruby.
After the installation is complete, you can check if the version you want has installed with the command rvm list
. Also, the version you installed should be the "current" one.
(Developers note: RVM Keys
current is marked with =>
current && default =*
default *)
Using a Specific Version of Ruby
You can use any version you want as long as it is anything after Ruby 2.3.0.
However, if you want to switch to a different version, say, 2.3.1, use the command rvm use 2.3.1
.
If you type rvm list
, you can see that the current one is now 2.3.1.
I highly recommend you read thru the RVM documentation to make yourself familiar with more advanced ways to make use of this tool.
As a last note, if you're installing RVM for the first time, you need to restart your terminal session. Just quit the terminal and reopen it.