Installing Ruby RVM on Ubuntu and Fedora

Installing ruby on Linux is easy, just run sudo apt-get install ruby or yum install ruby. However, version control can be difficult to manage. That is, scripts that run on a version on your computer may not run as well on another. So wouldn’t it be great if you could have 2 or more versions or the ruby interpreter on your computer.

To do this we will use the RVM – Ruby Version Manager. This is a great program, Allowing you to have complete environments for running ruby. This includes the interpreter and gems. And besides the few intricacies of setting it up, It is relatively easy to do.

My instructions are fairly similar to the official RVM instructions. You can find them at and more about RVM at there index page.

OK. Lets go..

Firstly make sure that you have a version ruby installed and curl for downloading the script (most distributions come standard with this, although minimal setups will not.

sudo apt-get install ruby curl

yum install ruby curl

Now make sure that you are logged in as the user that you want to install ruby for. This may be a no brainier however, if you have more than one user you may wish to install ruby for everyone or for a specific person. I would very much suggest NOT install RVM for everybody, because different users may choose to run different ruby interpreters which may cause problems latter on down the track.

Time to get dirty with the command line.

Open up a terminal session and cd to your home directory. The first thing is to download the install script and run it in bash

bash < <(curl -s

Once the script has run issue the following command to load RVM every time you login.

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

Now you need to close all your open terminal windows and then launch another. When the new one is open execute the following.

source .bash_profile

Now, to test that we have done all the previous correctly you need to use the following command and compare the results.

type rvm | head -l

The should output 'rvm is a function'

Thats it. Ruby Version Manager has been installed. Unfortunately, just having it installed is not much good, we need to look at gemsets and ruby versions, but that is for another post.


Ruby, The OOP language of the future

Ruby is AWESOME.

Yes thats right awesome. Ruby is a language that is both simple and powerful. It is completely object orientated, where everything that you work with is an object. That is numbers, strings, data structures and any program construct that you can think.

Created in japan by Yukihiro “matz” Matsumoto and released in 1995, It has since grown into a widely used langauge, in the top 10 listed languages on github project language page. This is mostly due to the natural order of programming, having a limited amount of clutter.

Ruby is also an interpreted language. We will go into this more later, but essentially means that it runs inside a special program that is built to take the ruby code and execute it. It is not necessarily the fastest interpreted languages, but it is one of the most powerful. There is a number of different interpreters, invoking different mechanisms and built in different languages (the major ones are c and java). This allows the user to implement different interpreters depending on the execution environment.

Lets look at some code, how about a hello world program. But first we need to install ruby on our machine. For ubuntu and fedora the code for installation is as follows.

sudo apt-get install ruby1.8 rubygems1.8

yum install ruby.i386 ri.i386 ruby-mode.i386

Now create a file named helloworld.rb and put the following line on the first line.

puts "Hello World!"

Yep thats it. Run it in the command line by using ruby helloworld.rb and it will output will be the string Hello World! This ease of use is due to mostly to the number of executed lines of per line of ruby code, averaging around 15 per ruby line.

Before continuing on with more examples, finishing of this post on ruby will be about ruby on rails, the new web programming application which comes inbuilt with its own web server and many other features.

Rails as its collectively known, was released to the public in 2003 by David Heinemeier Hansson, although now is actively developed by a team of 1600 community developers lead by a core team. The core concept behind rails is that it allows you to right the beautiful code of your ruby apps, in a web environment.

Thats about all for a first introduction of ruby, next time i will show you how to set up a working environment for deploying ruby on your machine (Linux first and then windows and mac). Why not read up on the ruby programming language.

%d bloggers like this: