While it is possible to install Ruby on a system-wide basis, it is much more common amongst the Ruby community to use a tool called rvm (Ruby Version Manager) to build and install Ruby and to manage the installation of Ruby gems (libraries). This tutorial will get you started with RVM on the MC 10 systems.
This tutorial assumes:
- You are working on one of the Linux systems in MC 10. Do not attempt this on obelix.
- You have at least 100 - 200 MB of free space in your GAUL account, depending on the Ruby gems that you install. You have at least 1 GB of quota, so this shouldn't be much of a hardship for you. If you need more quota to make this work, contact Jeff at [x@y, where x = jeff, y = csd.uwo.ca].
Open a terminal and install RVM:
\curl -L https://get.rvm.io | bash -s stable --auto-dotfiles
RVM is a script that supports both bash
and zsh
. You are likely using tcsh
, so you'll need to switch to bash
to use it:
bash -l
Make sure that you use the -l
flag.
Next, we'll install Ruby. If you execute the command rvm list known
, you'll see a list of all sorts of different Ruby interpreters and versions. We're simply interested in the standard Ruby distribution (known as MRI Ruby), and we'll install the latest version (2.0.0):
rvm install 2.0.0
This will take a few minutes. Once complete, you should execute the following command to indicate to RVM that you want 2.0.0 to be your default Ruby version:
rvm use 2.0.0 --default
Now type ruby -v
to make sure that it is indeed 2.0.0 that you are using:
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
Note that some of the details in your version string may differ from what you see above. As long as you have 2.0.0
in there somewhere, you're good to go.
Next, we'll want to install some gems. RVM overrides the standard gem
command to install your gems locally in your ~/.rvm
directory, but it is transparent to you. You can use the gem
command as you normally would.
When installing gems, both to save space and to reduce installation time, you will likely want to pass the --no-rdoc --no-ri
flags to the gem
command. This will avoid the installation of command-line documentation, which no one really reads anyway. Everything is online, after all.
Individual gems can be installed with the gem install
command. Examples:
gem install rails --no-rdoc --no-ri
gem install cucumber --no-rdoc --no-ri
gem install rspec --no-rdoc --no-ri
No one really installs individual gems these days. Instead, they use a tool called Bundler to manage their gems and associated dependencies.
Let's suppose we wanted to install Rails, RSpec, and Cucumber. We would create a file Gemfile
with the following contents:
source 'https://rubygems.org'
gem 'rails'
gem 'rspec'
gem 'cucumber'
To install the gems, we would then execute the following command from the same directory that contains Gemfile
:
bundle
That's it. The gems will then install and you'll be all set.
Bundler has a number of useful features, including the ability to pin gems at specific versions. For instance, if we wanted to install Rails 3.2.14, Cucumber 1.3.8, and RSpec 2.14.1, we would use the following Gemfile
:
source 'https://rubygems.org'
gem 'rails', '3.2.14'
gem 'cucumber', '1.3.8'
gem 'rspec', '2.14.1'
Bundler will take care of downloading and installing the correct versions, and will ensure that all installed versions are compatible with one another.