Tuesday, July 11, 2006

Installing Ruby and Rails Framework from behind a firewall

I think it is the frustration of not being able to do something very simple that often leads programmers to feel elated to see something as simple as the Hello World printed on the screen.

I mean, if you can do it with a simple "echo Hello World", why do you need all these fancy languages?

Anyway, I have been trying to go where probably a lot of men have gone before. But I am going to leave a map for those that follow.

Task: Install Ruby and ROR framework from behind a firewall.

Part 1. Installing Ruby.

This is faily straightforward.

Just click on the following link and that should give you the executable to install Ruby:

ruby182-15.exe

Note: Make sure C:\ruby\bin is in the path.

Part 2. Installing RubyGems.

Again, click on the link below to get RubyGems zip file:

rubygems-0.9.0.zip

Unzip file file. This will create a directory like C:\rubygems-0.9.0.

CD C:\rubygems-0.9.0
ruby setup.rb

Part 3. Installing Rails.

The documentation asks you to type "gem install rails --include-dependencies". But what if you are behind a firewall? Or even worse, don't have internet connection? It might seem impossible in this day and age, but there are people who don't have internet connection.

You will get a smug little error like:

ERROR: While executing gem ... (SocketError)
getaddrinfo: no address associated with hostname.

Not much descriptive is it? You won't find much help anywhere else either. But here is all the help you will need. This is what you do:

1. Open Internet Explorer and go to rubyforge gems subdirectory. Here, if you say that you don't have internet, well, you will need to go to a Net Cafe and download some files then....and copy these to a floppy.

2. Here, find the following files and save them to your local drive (I am assuming you are saving these to C:\).

a. actionmailer-1.2.3.gem
b. actionpack-1.12.3.gem
c. actionwebservice-1.1.4.gem
d. activerecord-1.14.3.gem
e. activesupport-1.3.1.gem
f. rails-1.1.4.gem

3. Next, go to command prompt and change directory to where you saved the gem files (C:\ in my case) and run the following commands one by one.

gem install activesupport
gem install activerecord
gem install actionwebservice
gem install actionpack
gem install actionmailer
gem install rails

Part 4. Running rails for the first time.

Run the following commands to create a skeleton rails application:

C:
CD rails rails
(This will create a sample application under C:\rails)
CD rails
ruby script/server
(This should kick off WEBrick)
Open a browser and visit http://localhost:3000

Initial WEBrick console should look like:

C:\rails>ruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-07-11 13:10:27] INFO WEBrick 1.3.1
[2006-07-11 13:10:27] INFO ruby 1.8.4 (2006-04-14) [i386-mswin32]
[2006-07-11 13:10:27] INFO WEBrick::HTTPServer#start: pid=57 port=3000

After you visit http://localhost:3000, it should look like:

C:\rails>ruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-07-11 13:10:27] INFO WEBrick 1.3.1
[2006-07-11 13:10:27] INFO ruby 1.8.4 (2006-04-14) [i386-mswin32]
[2006-07-11 13:10:27] INFO WEBrick::HTTPServer#start: pid=57 port=3000
127.0.0.1 - - [11/Jul/2006:13:13:25 GMT Daylight Time] "GET / HTTP/1.1" 304 0 - -> /
127.0.0.1 - - [11/Jul/2006:13:13:25 GMT Daylight Time] "GET /javascripts/prototype.js HTTP/1.1" 304 0 http://localhost:3000/ -> /javascripts/prototype.js
127.0.0.1 - - [11/Jul/2006:13:13:25 GMT Daylight Time] "GET /javascripts/effects.js HTTP/1.1" 304 0 http://localhost:3000/ -> /javascripts/effects.js
127.0.0.1 - - [11/Jul/2006:13:13:25 GMT Daylight Time] "GET /images/rails.png HTTP/1.1" 304 0 http://localhost:3000/ -> /images/rails.png

Press Ctrl-C here and that should shut WEBrick down.

So now you really don't have any excuse not to get onto Rails.

15 Comments:

At 2:36 pm, Blogger DeepaliAhirrao said...

Thanks Ashish this helped a lot.

 
At 1:42 pm, Blogger Abhijit Paranjpe said...

Ashish

I am getting the following error
while executing part 3

C:\>gem install actionmailer
ERROR: While executing gem ... (SocketError)
getaddrinfo: no address associated with hostname.

Please suggest a solution on that

 
At 1:45 pm, Blogger Abhijit Paranjpe said...

This comment has been removed by a blog administrator.

 
At 1:51 pm, Blogger Abhijit Paranjpe said...

I have downloaded the files mentioned in the blog.They are in zip files. Should I unzip them and then execute the command.

 
At 7:52 pm, Blogger John said...

What's wrong with the rubygems zip file (it seems to be corrupt).

 
At 4:41 pm, Blogger Ashish Kulkarni said...

Abhijit,

If you are using a ZIP file, you will need to unzip it.

Unfortunately these notes are a bit out of date and I have placed a more up-to-date version of these on the PuneRuby wiki at: http://www.puneruby.com/wiki/index.php/RubyQuickStart

 
At 12:38 pm, Blogger Raj said...

Hi Ashish,

Thanx a ton!
had been breaking my head for installing rails on my desktop , which is behind a firewall!!

Atlast found the stuff that i needed in ur Blog!!

Thanx a lot.
But one small query,
Is there any where i can download the gems required for working within a firewall.
think the site mentioned - http://rubyforge.vm.bytemark.co.uk/ is down.

Raj

 
At 4:53 pm, Blogger wongacid said...

thanks, it very helpfull. now my rails works on windows. thanks anyway...

 
At 2:43 pm, Blogger World is not enough said...

This is very helpful.
Latest set of files are -

actionmailer-1.3.2.gem
actionwebservice-1.2.2.gem
activesupport-1.4.1.gem
rails-1.2.2.gem
activerecord-1.15.2.gem
actionpack-1.13.2.gem

 
At 4:23 am, Blogger technobloggie said...

Interesting write up Ashish. I had written something similar some time ago.
It was called "Step By Step Tutorial To Set Up Ruby On Rails On One Of The most Popular IDE - Eclipse" and you can find it here
http://www.theblackpawn.com/step-by-step-tutorial-to-set-up-ruby-on-rails-on-one-of-the-most-popular-ide-eclipse.php

The html links would not work here so guess u have to follow it manually. I've updated my post with a link to your post so that it gives my readers something to leverage on :-).

Regards,
Gautam

 
At 10:22 am, Blogger mohammad said...

hi
I am getting the following error
while executing part 3

C:\>inistantrails/gem install actionmailer
ERROR: While executing gem ... (SocketError)
getaddrinfo: no address associated with hostname.

Please suggest a solution on that

 
At 1:23 pm, Blogger Nagu said...

Ashish..I still get the same error for each gem install command..any insight please?

 
At 6:56 pm, Blogger RakOU said...

Hats off to you, Thank you

 
At 7:04 am, Blogger ravi said...

Hi Ashish,

i am running the rails application behind the firewall

but in that application i have to connect the flickr site
so i cannot connect the my application into the flickr

please suggest solution on that

 
At 7:28 pm, Blogger Kathy Jacobson said...

Your updated notes on http://www.puneruby.com/wiki/index.php/RubyQuickStart are not there.

 

Post a Comment

<< Home