How to Install Ruby on Rails - Windows Guide - Part 1

In this guide, I will document by experience in installing and running a simple Hello World program in Ruby on Rails with suitable examples. There are so many guides and tutorials available on the web, that explains with video tutorials on how to install and setup Ruby on Rails for your operating system. (Windows, Linux, Ubuntu, Solaris and so on..) Then what is the point in me writing one more? This is not a guide, but rather an experience in following a guide and documents on what happened at every stage of the guide. This can serve as a handy reference for someone who would like to take a leaf out of this writeup. It can also probably help me in future as I can refer it back if required :). I'm dividing this into multiple parts depending on the length of the post. This is part 1 of the guide and let us get started with our journey on Ruby on Rails.

1) The first step towards installing Ruby on Rails, is to install the language Ruby. To do this, you will have to navigate to the Ruby installation page, and download a windows installer.Once you download the installer package, you can run it, accept the defaults. This will install Ruby under your C: drive typically. A sample directory structure post installation is provided below;
Ruby Directory Structure
Ruby Directory Structure
After installation if you execute ruby -v in command prompt (the installer should automatically update your path variales), you should get the version of Ruby installed in the output. In my case, the output was ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
2) Once you have installed Ruby,you will have to install RubyGems available at the same download location. But, what is RubyGems? You can think of RubyGems as an interface which will help you to download additional package files (GEM files, ex: Rails) and configure them for you to use with your Ruby installation. To install RubyGems, download the GEM file from the download location. Now, you need to place this file in a location which the "gem" command can accept. To find out this location, execute the command "gem environment" in command line. A sample output of this command is shown below;
gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.5.2
  - RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby192/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: C:/Ruby192/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby192/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby192/lib/ruby/gems/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
Now, GEM PATHS is the place where you have to place the downloaded GEM file. Once this is done, you can invoke"gem install rubygems"command to install RubyGems. A sample log of this installation is provided below;
C:\Ruby192\lib\ruby\gems\1.9.1>gem install rubygems
Successfully installed rubygems-update-1.8.5
1 gem installed
Installing ri documentation for rubygems-update-1.8.5...
Installing RDoc documentation for rubygems-update-1.8.5...
If you want to update the RubyGems version, you can invoke the command "gem update --system". An example log for this command is provided below;
C:\Ruby192\lib\ruby\gems\1.9.1>gem update --system
Updating rubygems-update
Successfully installed rubygems-update-1.8.5
Installing RubyGems 1.8.5
RubyGems 1.8.5 installed
* 1 minor enhancement:
  * The -u option to 'update local source cache' is official deprecated.
  * Remove has_rdoc deprecations from Specification.
* 2 bug fixes:
  * Handle bad specs more gracefully.
  * Reset any Gem paths changed in the installer.
------------------------------------------------------------------------------
RubyGems installed the following executables:
        C:/Ruby192/bin/gem
RubyGems system software updated
3)We are now ready to install Rails. Installing Rails on Windows is not all that complicated. It is infact, very straightforward and simple. First, you have to tell the gem command line utility, the location to search for Rails. This is done by adding an additional source for gem command to search, as shown below;
C:\Ruby192\lib\ruby\gems\1.9.1>gem sources -a http://gemcutter.org
http://gemcutter.org added to sources
Once this is done, you just have to execute one command to install Rails. And that command is provided below;
C:\Ruby192\lib\ruby\gems\1.9.1>gem install rails
Is is not that simple? This will install the Rails framework for you and a sample log for this installation is provided below;(big one)
Fetching: activesupport-3.0.7.gem (100%)
Fetching: builder-2.1.2.gem (100%)
WARNING: builder-2.1.2 has an invalid nil value for @cert_chain
Fetching: i18n-0.5.0.gem (100%)
Fetching: activemodel-3.0.7.gem (100%)
Fetching: rack-1.2.3.gem (100%)
Fetching: rack-test-0.5.7.gem (100%)
Fetching: rack-mount-0.6.14.gem (100%)
Fetching: tzinfo-0.3.27.gem (100%)
Fetching: abstract-1.0.0.gem (100%)
WARNING: abstract-1.0.0 has an invalid nil value for @cert_chain
Fetching: erubis-2.6.6.gem (100%)
Fetching: actionpack-3.0.7.gem (100%)
Fetching: arel-2.0.10.gem (100%)
Fetching: activerecord-3.0.7.gem (100%)
Fetching: activeresource-3.0.7.gem (100%)
Fetching: mime-types-1.16.gem (100%)
Fetching: polyglot-0.3.1.gem (100%)
Fetching: treetop-1.4.9.gem (100%)
Fetching: mail-2.2.19.gem (100%)
Fetching: actionmailer-3.0.7.gem (100%)
Fetching: thor-0.14.6.gem (100%)
Fetching: railties-3.0.7.gem (100%)
Fetching: bundler-1.0.14.gem (100%)
Fetching: rails-3.0.7.gem (100%)
Successfully installed activesupport-3.0.7
Successfully installed builder-2.1.2
Successfully installed i18n-0.5.0
Successfully installed activemodel-3.0.7
Successfully installed rack-1.2.3
Successfully installed rack-test-0.5.7
Successfully installed rack-mount-0.6.14
Successfully installed tzinfo-0.3.27
Successfully installed abstract-1.0.0
Successfully installed erubis-2.6.6
Successfully installed actionpack-3.0.7
Successfully installed arel-2.0.10
Successfully installed activerecord-3.0.7
Successfully installed activeresource-3.0.7
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.1
Successfully installed treetop-1.4.9
Successfully installed mail-2.2.19
Successfully installed actionmailer-3.0.7
Successfully installed thor-0.14.6
Successfully installed railties-3.0.7
Successfully installed bundler-1.0.14
Successfully installed rails-3.0.7
23 gems installed
Installing ri documentation for activesupport-3.0.7...
Installing ri documentation for builder-2.1.2...
Installing ri documentation for i18n-0.5.0...
Installing ri documentation for activemodel-3.0.7...
Installing ri documentation for rack-1.2.3...
Installing ri documentation for rack-test-0.5.7...
Installing ri documentation for rack-mount-0.6.14...
Installing ri documentation for tzinfo-0.3.27...
Installing ri documentation for abstract-1.0.0...
Installing ri documentation for erubis-2.6.6...
Installing ri documentation for actionpack-3.0.7...
Installing ri documentation for arel-2.0.10...
Installing ri documentation for activerecord-3.0.7...
Installing ri documentation for activeresource-3.0.7...
Installing ri documentation for mime-types-1.16...
Installing ri documentation for polyglot-0.3.1...
Installing ri documentation for treetop-1.4.9...
Installing ri documentation for mail-2.2.19...
Installing ri documentation for actionmailer-3.0.7...
Installing ri documentation for thor-0.14.6...
Installing ri documentation for railties-3.0.7...
Installing ri documentation for bundler-1.0.14...
Installing ri documentation for rails-3.0.7...
Installing RDoc documentation for activesupport-3.0.7...
Installing RDoc documentation for builder-2.1.2...
Installing RDoc documentation for i18n-0.5.0...
Installing RDoc documentation for activemodel-3.0.7...
Installing RDoc documentation for rack-1.2.3...
Installing RDoc documentation for rack-test-0.5.7...
Installing RDoc documentation for rack-mount-0.6.14...
Installing RDoc documentation for tzinfo-0.3.27...
Installing RDoc documentation for abstract-1.0.0...
Installing RDoc documentation for erubis-2.6.6...
Installing RDoc documentation for actionpack-3.0.7...
Installing RDoc documentation for arel-2.0.10...
Installing RDoc documentation for activerecord-3.0.7...
Installing RDoc documentation for activeresource-3.0.7...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for polyglot-0.3.1...
Installing RDoc documentation for treetop-1.4.9...
Installing RDoc documentation for mail-2.2.19...
Installing RDoc documentation for actionmailer-3.0.7...
Installing RDoc documentation for thor-0.14.6...
Installing RDoc documentation for railties-3.0.7...
Installing RDoc documentation for bundler-1.0.14...
Installing RDoc documentation for rails-3.0.7...
To see if you have installed Rails properly, run the command "rails -v". This should dump the version of Rails installed. I got an output of Rails 3.0.7 in my case. We are now ready to test a small program to see if the installation has happened correctly. Stay tuned.
Make sure you are connected to the internet when installing Rails in this fashion

No comments:

Post a Comment