Thursday, March 15, 2012

Installing Ruby on Rails in Linux Mint

I am adding new post to my blog almost after a year and half. It's not that I was not involved in any technical work or not learned any thing during this time, but for some strange reason I could not continue writing.

Anyway, here I am trying to learn Ruby on Rails (RoR) because it's been a long time since I've involved in real programming work. For the last few weeks I've been going through articles, tutorials, etc. on Ruby (and Rails) and learned a lot about its architecture. One thing I consistently doing while going through those materials is that when it came to installation and other configuration part, I used to skip the entire chapter. I wasn't realizing what I am missing until recently I tried to install Rails framework on my Linux Mint instance.

I got the ruby installed from Software Manager and rails using the command

$ sudo gem install rails

When rails is installed, I suddenly fired a command to create new website

$ rails new my_first_site -d mysql

Rails threw few strange error messages saying that it can't install mysql gem. Thinking that installing a MySQL server and client tool will help, I fired sudo apt-get install command to get them installed. I got disappointed when I still see those strange messages again. Realizing that it's time to get help from Google and I found the solution in no time. I actually needed MySQL library for Ruby. So, here it goes with the following command;

$ sudo apt-get install libmysql-ruby libmysqlclient-dev

Now it's time to install mysql gem.

$ sudo gem install mysql2

Rails created the new site properly and when I tried to run the server, it again threw strange error message. Don't know why but I always find messages in Linux very strange and cryptic. The message was about missing JavaScript engine ( though I find messages cryptic, I always read them correctly). Now, installing Node.js is simple;

$ sudo apt-get install nodejs

Phew!

Finally, I got the Ruby on Rails framework ready and I am all set for my practice session.

Update: Linux Mint doesn't have MySQL server and client pre-installed. The following command does the trick;

$ sudo apt-get install mysql-server