Computersnyou

How to install Ruby in Ubuntu 14.04 Via Source and Via RVM

Posted on  4/21/2014

In this tutorial I am going to show you , How you can Install Ruby via two different methods First by using source and Second Via RVM .

why we are using these two methods :
Simple we want to install latest version
if you are installing via apt-get method most of the chances are that it wont install latest version just because according to ruby-lang.org

Certain members in the Ruby community feel very strongly that you should never use a package manager to install Ruby and that you should use tools instead. While the full list of pros and cons are outside of the scope of this page, the most basic reason is that most package managers have older versions of Ruby in their official repositories. If you would like to use the newest Ruby, make sure you use the correct package name, or use the tools described above instead.

Note :
These Steps are tested on Ubuntu 14.04
I do not issue any guarantee that it will work for you , Please leave comment if you face any problem ,

Okay ,Lets get Started

PreRequisites

sudo apt-get update 
sudo apt-get install gawk g++ gcc make libc6-dev libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev 

Installing Via Source

Open terminal and type

wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz

It will download the source
Now use tar to extract the tarball ..

tar -xvzf ruby-2.1.1.tar.gz

Now change directory to ruby-2.1.1

cd ruby-2.1.1

now compile and install

./configure
make
sudo make install 

wait until it finish installing .

after installation type

ruby -v
which ruby 

it will print version number and binary location info .

ruby version
ruby version

official instruction

Installing Via RVM (Recommended )

sudo apt-get update 
sudo apt-get install curl git-core -y 

Now Lets install RVM first

\curl -sSL https://get.rvm.io | bash -s stable
source $HOME/.rvm/scripts/rvm

now restart your terminal and lets test rvm installation

type rvm | head -n 1

if it returns rvm is a function it means things are working correct .

okay, Lets install ruby ,
If you want to see list

rvm list known 

Lets install ruby ruby-2.1.1

rvm install ruby-2.1.1 

it will take some time and install ruby 2.1.1 for you

ruby installing
ruby installing

Okay Lets tell rvm to use that ruby

rvm use 2.1.1 --default 

now again test ruby version and binary location

ruby --version
which ruby

It will show you version number and binary location

Happy Coding ….


  • Home
  • About