Ruby中 gem proxy代理设置方法

今天想下载bundler提示:

C:\**********dev>gem install bundler
ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - no such name (https://rubygems.org/specs.4.8.gz)

windows可以设置代理软件,或者是使用http_proxy:在命令行输入:set http_proxy=url,后面的url是你的代理地址,如:http://192.168.0.1:8081,这样做的结果就是让自己的命令行会自动使用代理进行网络的转发,下次重新打开命令行会自动失效,而不是单纯的使用gem的代理,所以可能不是最切实的实现方式,不过这样一般都能达到目的。

取消代理:
set http_proxy=
然后回车,即等号后面什么都不写

查看代理:
set http_proxy

如果相对gem进行单独的proxy代理的话可以使用:

gem list -p http://proxy:8080

完成之后gem就会从你设置的代理中进行数据的访问和传输了。

gem help 
gem help commands 
gem sources -h 
gem sources -l 
gem sources -r https://rubygem.org/ 
gem sources -a http://ruby.taobao.org
 

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:

  1. Download rubysspi from the Ruby Win32 SSPI project page(also available as gem install rubysspi but that doesn’t help much, does it?)
  2. Install the gem locally
  3. Copy spa.rb from the gem install to your site-ruby directory
  4. Find gem.cmd in your ruby bin directory and add ”-rspa” to the command line.
  5. Set http_proxy environment variable as above
  6. gem list rails

猜你喜欢

转载自blog.csdn.net/qq_35851073/article/details/84616960