Setting up Rails in Ubuntu

Setting up Rails in Ubuntu

This week my Mac Book Pro had another kernel panic and while I understand these things happen sometime, this was one of a series I have been having since I acquired it a few months ago. After taking it in to the Apple Store's 'Genius Bar', I was told it would need to be held overnight to repair it.

Not wanting to be out of communication, nor access to my code, it was time to pull out my old System76 lemur ultrathin laptop that was nearing six years old. It had a floppy lid and the battery life could be counted in minutes on your hand.

I had been using Ubuntu GNU/Linux for some years now, I wanted to move away from Windows after having several infuriating license issues and just simple desire to try something new.

Setting up a decent coding environment is much like how it is in OSX, only you are blessed with a proper package manager and you do not have to sign any license agreements to create a Hello World app.


I use RVM in OSX, as it allows you to deal with multiple versions of Ruby per project. If you open up your trusty command line (this can be done through Ubuntu's Software Center, but it is much more cumbersome), and first make sure your repo list is up to date:

sudo apt-get update

You should have curl installed by default if not run sudo apt-get install curl, then we want to grab RVM along with Rails so run this command:

\curl -sSL | bash -s stable --rails

It will run through, download, and install RVM along with Rails. It might ask you a few questions on your personal setup. After that is done, you want to make sure your shell is connected to RVM's scripts:

source ~/.rvm/scripts/rvm

Let us also add this to our shell config:

echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc

Lastly, see if there are any additional requirements:

rvm requirements

If that gives you weird errors, you can try to run everything through the apt-get way:

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libgdbm-dev libncurses5-dev automake libtool bison libffi-dev

Grab Ruby:

rvm install ruby

Then RubyGems:

rvm rubygems current

If you skipped out on installing Rails or had an error, run:

gem install rails

That should be it!

Let's try it

Ok, everything should be ready to go to create a Rails app. Run:

rails new blog

Did everything work ok? If not, you might want to go back and make sure Rails is installed, RVM is not acting up again, or you are in fact mistaken and are attempting these commands in Windows ME.

Go to your new app:

cd blog

Now let us push this baby to Github.


We all use Git, though I remember when Ubuntu required Bzr for everything in Launchpad. In addition to Git, the hosted Git service Github is also widely used including myself. Let us set it up:

sudo apt-get install git

I am assuming you have created an account on Github already, if not do so, then create a test repo. I like to have a personal repo to host my emacs config. After you have created an account, you will want to set your name and email:

git config --global "Chris Hardee"
git config --global ""

Now let us create this repo, add everything to it, then commit it all:

git init
git add *
git commit -a -m "Initial Commit"

Now we want to add the url origin that Github provided:

git remote add origin<username>/<repoName>.git

Last we push:

git push -u origin master

Everything work ok? If not you might want to make sure you are authenticated on Github.


That should be it for setting up your environment! No need for homebrew, RailsInstaller, etc etc. You will probably need to pull down the correct database that you want to use for your Rails app, but since that really depends on what you want I will leave that in your (Google's) hands.

Need any cross platform Rails development work? Let us know!


Categories: Software Development, Environments | Tags: Rails, Ubuntu, Linux

Portrait photo for Chris Hardee Chris Hardee

Developer at Grok-Interactive and first full-time employee. Develops in Rails & PHP, along with projects for/involving Expression Engine, Responsive Web Design, and Mobile Applications. When he is not developing he helps run the San Antonio hackerspace



We provide a free consultation to discover competitive advantages for your business. Contact us today to schedule an appointment.