Subscribe to the goodies

Email Address

Back to the Basics: Setting Up Desktop Ubuntu for Rails

Jim–Monday, 2 June 2014

I’m sure this is one of thousands out there that gives a step by step instruction on how to setup a dev environment in Ubuntu for Rails. This is more of a personal preference on setting up my dev box which includes installing terminator, vim and a few other goodies that I always find myself googling when I’ve reinstalled a new ubuntu version. I hope this helps someone without a mac out there :D

Step 0: PRE INSTALL NOTES

Backup your ssh credentials. When I installed ubuntu last April, I had to ask my colleagues to update my ssh pub file in order for me to be able to login to our servers. It’s too much of a hassle but there’s no way to retrieve it so please don’t forget to do this if you’re reinstalling ubuntu.

Search the software center first for a package before you visit a site and install a downloadable .deb file. Sometimes, the downloadable installer just isn’t working. I’ve had issues trying to install dropbox because of the installer I downloaded from their site.

Step 1: Installing Ubuntu

Download the latest ubuntu version. As of this writing, the latest version is 14.04, Trusty Tahr. This is also a long term support (LTS) version which means that this version will continue to receive security updates for 5 years compared to non-LTS version which only receive security updates for 1.5 years. There’s a list of releases and when their support date ends in the ubuntu wiki.

Once ubuntu is installed, you’re done with the longest part of this process :)

Step 2: Installing Git

Git is now the de facto standard for version management. It’s also required by some of the items that we’ll install so we need to install this first. To install git, just open a terminal and run

sudo apt-get install git-core

Step 3: Installing Terminator

I actually don’t remember when/why I started using 4 terminals when coding.

I use one window for running the rails server. The main purpose of this one is for debugging purposes. If you have 3 other windows where you can open other files, you can easily see where/why/what a methods/variables are called/defined.

Usually, the other window is used for a rails console or running a background job or running a test. The other 2 windows are where I really open files for coding.

To manage these terminals, I use an application called terminator. Install it using

sudo apt-get install terminator

Step 4: Installing Vim

I use vim for editing files. I don’t use any plugin manager for vim, yet but if you want to use one, I suggest using vundle.

sudo apt-get install vim

Step 5: Installing RVM

In NetEngine, most of the developers are using rbenv as the ruby version manager. I prefer rvm simply because it’s more intuitive for me. The big disadvantage of rvm over rbenv is its installation process. If you look at the installation wiki on the rvm site, there are a lot of things you need to consider when installing rvm. The following code installs rvm for a single user

Once that’s done, install the latest ruby version using rvm install ruby. If you need to install a specific version, you can check the list of versions available to install using rvm list known. To install MRI version 2.1.2 and make it the default version, use the following

rvm install 2.1.2
rvm use 2.1.2 --default

If you’re running rails 2 and you get an undefined method 'source_index' for Gem:Module, you need to downgrade the rubygems version. Use the following command to do so

rvm rubygems 1.8.25 --force

Step 6: Installing Dotfiles

We all want a personal touch/configuration on our dev box. One really good way to save these settings is to create a dotfiles repo in github and push your files in the repo. I suggest you create the files without the dot at the start and just symlink it.

Step 8: Creating a Postgresql User

Whenever I install postgresql, I’ve always had to allot time to searching for a way to create a postgresql user. Not anymore. In order to let rails create/drop the database for you (by running rake commands), you have to setup the user permissions. Usually, it’s the name of the user logged in to the account so we’ll do that.