Install Ruby in Ubuntu 12.04

This simple tutorial will show you how to install Ruby in Ubuntu 12.04,you can choose to install it with or w/o RVM (Ruby Version Manager) Now the latest version of Ruby is 1.9.3 ,so we will show you how to install this version.


Install Ruby without RVM


1.Open a terminal by pressing Ctl+Alt+t

2.Run below commands in your terminal to install ruby 1.9.3

sudo apt-get update
sudo apt-get install ruby1.9.3

3.Verify the installation use below command

ruby --version


sudo apt-get remove ruby1.9.3
sudo apt-get autoremove



Install Ruby with RVM


1.Run below command in your terminal to make sure your repository is up to date

sudo apt-get update

2.Run below commands to install curl/ install RVM /load RVM

sudo apt-get install curl
curl -L | bash -s stable
source ~/.rvm/scripts/rvm

3.Install RVM dependency packages

First run below command

rvm requirements

then follow the instruction to install dependency packages ,eg:

rvmsudo /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

Note:If you get error like “zlibxxx is missing”,please install zlib use command

rvm pkg install zlib

4.Install ruby 1.9.3 via RVM using below command

rvm install 1.9.3

5.If you have other version of ruby installed ,use below command to set version 1.9.3 as default and verify

rvm use 1.9.3 --default
ruby --version

Leave a Reply

Your email address will not be published. Required fields are marked *