Sunday 26 February 2012

Rails 3 on Ubuntu11.04 (11.10)

It seems that when asked how to install Rails on Ubuntu everyone immediately points to RVM and to be honest, there are many good reasons to. Just in case you don't want to use RVM for whatever reason and choose to walk the other path, there are plenty of pitfalls to consider there.

Things to note:
I'm starting with a new Ubuntu Server 11.04 on a VirtualBox  (Edit:Version 11.10 as of 26/02/2012)

The only commands I've used before this is sudo apt-get install xinit and sudo apt-get install fluxbox but I am not running either of those packages while getting ruby or rails. I just like having a text editor and terminal up at the same time.


Edit: This also works exactly the same on Ubuntu Desktop x64 v11.10

Installing without RVM


We are going to need the compilers included in build-essential in order to build native extensions of gems later.
sudo apt-get install build-essential 
We are going to need sqlite3 also
sudo apt-get install sqlite3 libsqlite3-dev
The name is ruby1.9.1 but this is 1.9.2, testable by using the ruby -v command after you have installed it. Also you must use the -dev version as the ruby1.9.1 does not include some dependencies needed to run itself due to the Debian packaging system (according to a Google search)
sudo apt-get install ruby1.9.1-dev
sudo gem install rails
Rails at this point will not run as we will not have a Javascript engine. TheRubyRacer is officially advised against by Heroku so lets go for Node.Js for now
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
You should now be adle to start a Rails app and run Rails server without Rails yelling at you about Javascript.
Now is the time to install any gems you like, lets go for RSpec and Cucumber and their Rails variants to start with.
sudo gem install Rspec
sudo gem install Cucumber
sudo gem install Rspec-Rails
Before we can install the cucumber-rails gem we need to make sure we have a couple more packages or we will experience strange errors.
sudo apt-get install libxslt-dev libxml2-dev
Now we can get Cucumber-Rails in peace
sudo gem install Cucumber-Rails

If there is anything missing please comment below so others can see it.
I will keep updating this post with any error messages that you can encounter along with their fixes so people can google their way here, in making this I ran into multiple errors that were unique or variants of other errors only.
~Greg Myers
~BookOfGreg

No comments:

Post a Comment