A Copy & Paste Solution to Get Rails Up and Running
Ubuntu has cleared the way for Linux onto the desktop – not even for the nerds vegetating in dark basements, but especially for the regular everyday user. With a well balanced bundling of packages and preconfiguration, the Ubuntu developers provide a simple “fire and forget” solution: Just insert the installation medium, walk through a few simple wizard-steps, and reboot into a full-fledged productive system providing everything you need – from browser and email-clients to office, multimedia and image manipulation. Just enough to fulfill your everyday tasks without having to worry about downloading and installing 1.000 different applications by hand.
But these presets have their limits when it comes to the everyday needs for developers. Don’t get me wrong, the apt package management makes it easy to install all your required packages. On the other hand, researching and installing all these requirements can be a very time-consuming task.
When we're talking about a development environment for Ruby on Rails, these requirements can quickly become overwhelming: databases and corresponding management tools, source and header packages for a wide variety of gems including dependencies, rvm/rbenv, version control system, IDE and dependencies, and a lot more. Installing all that stuff with a GUI powered application like synaptic or the Ubuntu Software Center will definitely be a pain in the ass. But don't despair: as developers, we have our beloved console coming to our rescue.
To get the core up and running with all necessary libraries and development headers, just copy and paste the following lines into your terminal:
sudo apt-get install synaptic curl zlib1g-dev libyaml-dev nodejs \ build-essential sqlite3 libsqlite3-dev openssl libssl-dev autoconf \ vim git git-core git-gui gitk gitg libxml2-dev libxslt1-dev libyaml-dev \ libtool mongodb libreadline6 libreadline6-dev libxslt-dev libc6-dev \ ncurses-dev automake libtool bison pkg-config libffi-dev \ libgdbm-dev imagemagick libmagickcore-dev libmagickwand-dev
You may require some other database systems in addition to SQLite, depending on what suits you best. Just use one of the following lines to install the libraries and servers for alternative database systems:
#MongoDB for all the NoSQL lovers ;) sudo apt-get install mongodb #MySQL sudo apt-get install mysql-client mysql-server \ libmysqlclient-dev libmysqld-dev #PostgreSQL sudo apt-get install postgresql libpq-dev
Now let's jump over to our beloved Ruby core. Below you can grab the lines to setup a Ruby environment with RVM:
curl -L get.rvm.io | bash -s stable --auto source ~/.rvm/scripts/rvm . ~/.bash_profile rvm requirements rvm list known # to list all known rubies rvm install 2.0.0 #Install the latest ruby rvm use 2.0.0 --default #Set 2.0.0 as the default ruby gem install bundler rails #Install bundler, rails to get startet
The lines above leave you with the 2.0.0 version of Ruby. You can also install multiple versions in peaceful coexistence, e.g. rvm install 1.9.3 and switch between installed Rubies with rvm use 1.9.3.
Next, we definitely want some version control magic with git and the Heroku toolbelt for easy deployment.
#Git/Github configuration git config --global color.ui true git config --global user.name "Git Hubert" git config --global user.email "firstname.lastname@example.org"
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
Final step: An editor that suits you
After playing around with a lot of different editors and IDEs for Ruby/Rails, I ended up with Sublime Text 2. It's lightweight, blazing fast, highly and easily customizable, and it comes with built-in Rails support. Give it a try (if you haven't already):
sudo add-apt-repository ppa:webupd8team/sublime-text-2 sudo apt-get update sudo apt-get install sublime-text
Yay, we're done. Wasn't that hard, was it? Now grab yourself a cup of tee, an oversized pizza, shut the doors and start coding.