Mostrar / Ocultar Avisos

Trying to Install Ruby Gems On Windows Though a Proxy Server

As with most larger businesses we have a corporate firewall which can lead to small annoyances, such as not being able to connect to rubyforge.org to download new gems. I recently had a new hard drive installed at work so, of course, I had to spend too much time reinstalling all of my development tools. Visual Studio 2005 takes way too long, btw.

Yesterday, I spent a good hour trying to get Rails with the standard gem install rails –include-dependencies. No luck due to our firewall. So I checked the ruby gems doc to find the correct install parameters. Still no luck. No matter which combination I tried to tell gem to look remotely through the proxy server it still wouldn’t go. So I asked the Google to help out and after reading through blog entries and message boards I stumbled upon one that talked about setting environment variables in linux. Well, I’m a windows guy so that didn’t help much but it gave me the idea to try and set a Windows environment variable. What the hell, right?

So, I added a User Variable for my account called http_proxy with the value of http://<proxyserveraddress>:8080, rebooted, ran plan old vanillia gem install rails –include-dependencies, and magically, it worked. See below the fold for details.

  1. Right click on My Computer and select Properties from the menu.
  2. Select the Advanced tab.
  3. Select the Environment Variable button.
  4. System Properties
  5. Select the New button in the User variables section.
  6. Give the new variable a name of http_proxy.
  7. Give the new variable a value of http://<proxyserveraddress>:8080 and replace <proxyserveraddress> with the name or IP address of your corporate proxy server.
  8. Environment Variables
  9. “OK” out of the three windows
  10. Reboot
  11. Run gem install rails –include-dependencies from the command line.
  12. Sit back and let the install fly.

You could also set a system wide environment variable if you wanted. Your choice.

Leave a Reply