Sunday, September 5, 2010

Rails for windows developer

I have been working in the Microsoft world for too many years.  Every time I attempt to venture in to learning ruby on rails, I end up setting up every thing from scratch and spend tons of time to get started.  And leave all of that to only start again after few months.  It feels like I am doing this over and over again.  Finally I decided to write down the instructions needed to set up Rails development environment on Ubuntu virtual machine.

  • Do not use windows environment to develop on Rails.  You cannot stand the friction after a while.  Not much support in the community if you are struck.

  • I found it best to use Ubuntu on a virtual machine. I tried to use  Wubi, which is a fantastic tool. But duel booting means rails environment is not a click away.  And a number one reason for not spending much time on rails learning.

  • If you are taking rails seriously you mush be comfortable with either mac or unix environments.

  • I decided to use ubuntu as I would like to have rails on my windows machine via vmware workstation.  VirtualBox will do fine.

  • I tried multiple IDEs and finally settled on RubyMine.  This choice is a no-brainer as I am used to Resharper on visual studio.
Setup instructions

  • Install vmware workstation

  • Insall ubuntu on vmware.  Grab the iso files from ubuntu.  I used 10.1 beta.   15GB space and 1GB RAM

  • Create a shortcut for Terminal on the panel.  You will be using this a lot.

Installing ruby, rvm and rails
Open the terminal and type the following at the prompt
sudo apt-get install curl git-core ruby
Install rvm by typing the following
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
At the end of the installation, change the .bashrc file.  Type the following at the command prompt

gedit .bashrc

Replace the following text in .bashrc file
[ -z "$PS1" ] && return
with
if [[ -n "$PS1" ]]; then

And add the following to the end of the file

if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi

fi

Verify the installation of rvm by typing

rvm -v

Close the terminal and reopen it

Install ruby 1.92 packages by typing the following at prompt


sudo aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev
libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf

Use rvm to install ruby 1.9.2 by typing the following command


rvm install 1.9.2-head

Set default ruby version in rvm

rvm --default 1.9.2-head
Type the following at the prompt

ruby -v

You should see the following

ruby 1.9.2p0 .....

Now ruby set up is done.  Type the following at the prompt to install Rails


gem install rails

That is it!  Rails is now installed on your ubuntu setup

Installing RubyMine IDE
I used 2.5 EAP version of RubyMine

Grab RubyMine-<version>.tar.gz file.  And extract that to a known folder using default ubuntu archiver

Move the unpacked rubymine to /opt/rubymine by typing the following command at prompt


sudo mv RubyMine-96.1085 /opt/rubymine

Create an app launcher on the panel bar.  Right click on the panel and choose add to panel and create custom application launcher

Set the command option to opt/rubymine/bin/rubymine.sh

Choose the icon from opt/rubymine/bin/rubymine.png

Installing Sun Java
RubyMine needs sun java, which is not installed on ubuntu.

Open System --> Administration --> Software sources --> Other Software

Check all the check boxes pointing to http://archive.canonical.com/ubuntu maverick

Open Applications -> Ubuntu Software Center and search for sun java

Install sun-java6-bin, sun-java6-jre, sun-java6-fonts,  , sun-java6-jdk, sun-java6-plugin

Type which java at command prompt.  It should show /user/bin/java

Rubymine needs a symbolic link for java in bin folder.  Type the following command at the prompt

sudo ln -s /usr/bin/java /bin/java

Now you should be able to start RubyMine

No comments:

Post a Comment