gem install watir - 错误:执行gem(Net :: HTTPServerException)407"需要代理身份验证"

时间:2017-11-22 11:37:39

标签: ruby proxy permissions rubygems

这让我疯了 - 在过去的三天里我到处寻找解决方案......到目前为止,没有任何工作可行。

星期一,我在尝试安装watir时收到此错误:

C:\Users\dan>gem install watir 
ERROR: Could not find a valid gem 'watir' (>= 0), here is why: 
Unable to download data from https://rubygems.org/ - timed out 
(https://api.rubygems.org/specs.4.8.gz) 

因此认为这是防火墙/代理错误。为了尝试解决这个问题,我使用了--http-proxy选项:

C:\Ruby24-x64\bin>gem install watir --http-proxy http://my.awesome.proxy:port
ERROR: While executing gem ... (Net::HTTPServerException)
407 "Proxy Authentication Required"

然后我尝试使用我定义的用户名和密码来运行它,但是如果我的密码包含一个特殊字符(它可以),我已经读过它将无法工作:

C:\Ruby24-x64\bin>gem install --http-proxy http://myusername:mypassword@my.awesome.proxy:port watir
ERROR: While executing gem ... (Net::HTTPServerException)
407 "Proxy Authentication Required"

然后我尝试使用set选项设置HTTP和HTTPS的代理,用户名和密码,如下所示:

set HTTP_PROXY=my.awesome.proxy:port
set HTTP_PROXY_USER=myusername
set HTTP_PROXY_PASS=mypassword
set HTTPS_PROXY=my.awesome.proxy:port
set HTTPS_PROXY_USER=myusername
set HTTPS_PROXY_PASS=mypassword

...但我仍然得到407错误。有什么想法吗?

我在Windows 10上,我的宝石环境详情如下:

C:\Ruby24-x64\bin>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.2
  - RUBY VERSION: 2.4.2 (2017-09-14 patchlevel 198) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby24-x64/lib/ruby/gems/2.4.0
  - USER INSTALLATION DIRECTORY: C:/Users/dan/.gem/ruby/2.4.0
  - RUBY EXECUTABLE: C:/Ruby24-x64/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby24-x64/bin
  - SPEC CACHE DIRECTORY: C:/Users/dan/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Ruby24-x64/lib/ruby/gems/2.4.0
     - C:/Users/dan/.gem/ruby/2.4.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

@Beartech:

C:\Ruby24-x64>ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 1.0.2l  25 May 2017

MINGW64 ~
$ openssl s_client -host rubygems.org -port 443
connect: Connection timed out
connect:errno=116

1 个答案:

答案 0 :(得分:1)

终于解决了!一位同事与Atom的插件列表有类似的代理问题,因此我指出了正确的方向。

命令是:

gem install --http-proxy http://{domain}%5C{username}:{password}@{proxy.address}:{port}/ watir