Question : Install Ruby Gems through a Firewall?

I'm at work and would like to be able to play with ruby.
However whenever I try to update gems, I get the following:

1:
2:
3:
4:
5:
6:
7:
C:\>gem update --system
Updating RubyGems
ERROR:  http://rubygems.org/ does not appear to be a repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNREFUSED: No connection could be made because the target machine
actively refused it. - connect(2) (http://rubygems.org/yaml)


I read something somewhere about installing apache\firewalls\proxy gem installation,
but I don't really know anything about this.

is it possible for me to install gems

thx,
-JW
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
C:\>ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]

C:\>gem -v
1.3.7

C:\>gem list

*** LOCAL GEMS ***

rubysspi (1.3.1)

C:\>

Answer : Install Ruby Gems through a Firewall?

'gem' just uses HTTP for downloading gems, so if your firewall flat-out does not allow HTTP (web traffic) through it, it's not going to work.  

But if your environment expects the use of a proxy, then 'gem' can be made to work (probably).  

(Note: make sure you've read and understand your organization's internal computer and web usage policies.  Obviously, if any of the actions suggested below may violate them, do not proceed.  While I don't believe anything suggested here is illegal --- it isn't in my jurisdiction --- that doesn't mean it won't be grounds for termination in your organization.)

To cut to the chase, if you know the URL for the proxy in your environment, simply give that to the 'gem' command, like so:
  gem update --system -p http://proxy_host.your_site.net:port/
(Replace "proxy_host.your_site.net" with your proxy value.)

If you don't know if you have a proxy being used or not, open up your web browser.  For IE, go to Tools -> Internet Options.  Select the Connections tab.  Click the "LAN Settings" button.  If the "Use a proxy server..." checkbox is checked, then the address and port specified are your proxy server.  So for example, if the address were '1.2.3.4' and the port was '8080', then you would use the proxy URL of 'http://1.2.3.4:8080/' in the 'gem' command.  For Firefox (3.5+), you select Tools -> Options.  Select Advanced, then the Network tab.  Click the Settings... button.  Again note the address and port.  (If you have a different browser, look at its documentation about setting the proxy and follow it to determine the value.)  Of course, this all assumes that it has been manually set.  If your IT has administratively set this, you may not be able to view it.  (And if they are auto-detected, then it may become harder to find out what they are.)

Now if you've found the proxy setting but the 'gem' command still doesn't work, you can check if you're generally prevented from the sites.  (Please give any error you get, in this case.)  In your browser, try going to 'http://rubygems.org/'.  (Also try 'http://gems.rubyforge.org/'.  It's the same content, but if one worked and the other didn't, it would help understand what's going on.)  If you can't get to that site with the browser, then the firewall/proxy is preventing access (presumably; there may be other problems outside of your organization.)  At that point, you would have to decide whether to make the request to allow access to these sites or not.

If the browser worked, then try 'http://rubygems.org/yaml'.  If you get an error rather than being prompted to save a file, your proxy may not allow unknown file types to be downloaded, so again you'd have to weigh talking to IT.  If that does work, the IT possibly is restricting access by "unacceptable" clients.  The best option in this case may be to download the individual gems with the browser and install them locally.  For example, if you've downloaded 'rake-0.8.7.gem', you would install it like this:
  gem install rake -l
The big downside of this method is that you have to download all dependent gems before installing.  You will be told that you missed a dependency and thus can go and download that gem next.  But that potential repetitive process is handled for you by the 'gem' command.

Let me know if that works.
Random Solutions  
 
programming4us programming4us