Friday 9 September 2011

How to install Ruby and RoR on Window Platform?

RUBY Installation on Window
Files required:
1) ruby installer for window : Ruby 1.9.2-p290
2) development kit : DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe

Download and proceed installing Ruby as you normally do with any insaller... :P.
I've installed ruby inside my 'c:/'  dir. So, it's path is "C:\Ruby192"

I've put develpment kit insde this folder underneath  'devkit' folder.

For development kit:
Extract the dev-kit folder anywhere. I've extracted it inside  'C:\Ruby192' folder .

Goto the root folder where you extracted DevKit, which in my case is 'C:/Ruby192/devkit/ ' and execute undersign commands
ruby dk.rb init
ruby dk.rb install
Second Step:   Tell window about ruby and devkit
Once you done installing ruby and devkit, you need to add their path in window envrionment variables i.e PATH.
so... right click on "My computer" from anywhere ( start menu or through window explorer) then click properties and then  look for advanced setting tab and there look for "environment variables" under 'advanced' tab.
We have to edit one "system variable" :  PATH.
so , find and edit.
append the path to your  bin directory of ruby and path to bin directory of devkit in path variables , so that your final path variable look like this. Don't forget to separate them by semi-colon(;);

C:\pik\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Bazaar;C:\Program Files\cloudControl;C:\wamp\bin\php\php5.2.8;D:\git\bin;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files\GnuWin32\bin;C:\Program Files\Notepad++;C:\Program Files\Android\android-sdk\tools;C:\Program Files\Android\android-sdk\platform-tools;C:\pik;C:\Ruby192\bin;C:\Ruby192\devkit\bin

once you done adding path to of devkit and ruby you're ready to install RoR :ruby web framework.
Now,  update your gems by running undersign gem`s update command:
>>gem update --system
Hug yourself,  you've just finish installing Ruby all by yourself. :D
Next step is to install RoR:ruby on rails.

RoR: Installation on Windows
To install Rails which is just like another gem in reign of ruby, i assume you have already successfully installed ruby and development kit.
open the command  prompt and type
>>gem install rails --include-dependencies
Now, you're done installing Rails as well. 
TEST IT:
>> rails new  myNewApp

reference:
devkit: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

Errors that you may face:    
>>gem install rails

DevKit is needed because rails requires the json gem. Without installing DevKit you would get the error:
ERROR: Error installing cucumber:
The 'json' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
This is likely to happen if you've installed devkit.So, again check if you've installed devkit and if yes, then make sure that you've added right path in window Environment variable(PATH) i.e you've appended path to devkit's /bin directory in  PATH variable.