公司里上网是通过公司自己做的代理,因此使用Rubygem的时候没有办法直接安装我们需要的包如Rails,在网上查了很多的有关gem使用代理的方法,很多人都写到gem支持-p参数来设定代理,但是我试了很久没有成功。 现在把我设置成功的方法记下来,以免以后忘掉:
在windows里有两种,第一种是使用代理软件,这个我就不说了,自己看着办吧;
第二种,在命令行下输入:set http_proxy=url,后面的url是你的代理地址,如:http://192.168.0.1:8081什么的。设置完后就可以直接使用gem命令了。
下面是官方的原文:
Running gem install when you are behind a proxy.
Set the HTTP_PROXY environment variable.
Note this is fully qualified, as such:
http_proxy=http://URL:PORT
http_proxy=http://127.0.0.1:5865
in this example, the proxy is running on the localhost. With NTLM authorization to get through a corporate firewall.
NB: This may not work if you are behind a Microsoft ISA Proxy server with only NTLM (MS ISA Server proprietary) authentication available. If this is the case, you can try the Microsoft Firewall Client or the Python NTLM Authorization Proxy Server.
JB: A gem is available which gives ruby the ability to authenticate with ISA natively. To use it with gems follow these steps:
- Download rubysspi from the Ruby Win32 SSPI project page(also available as gem install rubysspi but that doesn’t help much, does it?)
- Install the gem locally
- Copy spa.rb from the gem install to your site-ruby directory
- Find gem.cmd in your ruby bin directory and add ”-rspa” to the command line.
- Set http_proxy environment variable as above
- gem list rails
希望这些能对大家有用!!!
在公司使用代理服务器的情况下,安装Ruby gem如Rails时需要设置代理。可以通过在命令行设置http_proxy环境变量,例如`set http_proxy=http://192.168.0.1:8081`。如果遇到NTLM授权问题,可以考虑使用Microsoft Firewall Client或Python NTLM Authorization Proxy Server。另外,可以借助rubysspi gem进行ISA服务器的原生认证。
495

被折叠的 条评论
为什么被折叠?



