Install ruby 2.0.0, rails 4.0.0 with rbenv on Ubuntu 12.04 LTS

I use rbenv instead of rvm siimply because rails recommended it.  If you had set up rails/ruby/rvm on your machine before, remember to uninstall them first.

To uninstall ruby

$ sudo apt-get remove ruby

To uninstall rvm

$ rvm implode

also remember to clear rvm reference in .profile .bashrc .bash_profile (hope I don’t miss any).

Let’s get started, assuming git is installed.

Update your ubuntu

$ sudo apt-get update
$ sudo apt-get upgrade

Install common libraries: (though I’m not sure whether all are necessary)

$ sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev

Install javascript runtime

$ sudo apt-add-repository -y ppa:chris-lea/node.js
$ sudo apt-get -y update
$ sudo apt-get -y install nodejs

Install rbenv

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
$ echo 'eval "$(rbenv init -)"' >> ~/.profile
$ exec $SHELL -l$ source ~/.profile

check rbenv

$ rbenv

Install ruby-build

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Install ruby

$ rbenv install 2.0.0-p247
$ rbenv global 2.0.0-p247
$ rbenv rehash

check ruby

$ ruby -v

Install rails

$ gem install rails --version 4.0.0 --no-ri --no-rdoc
$ rbenv rehash

check rails

$ rails -v

Credit:  I want to thank Tim Abell as I borrow his steps from installing rails. I spent quite sometime on figuring out to use the rbenv rehash after gem install rails. You can check Tim’s post at: http://timwise.blogspot.hk/2013/05/installing-ruby-2-rails-4-on-ubuntu.html.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s