gem install watir - ERROR: While executing gem (Net::HTTPServerException) 407 "Proxy Authentication Required"

gem install watir - ERROR: While executing gem (Net::HTTPServerException) 407 "Proxy Authentication Required"

这让我抓狂 - 在过去的三天里,我到处寻找解决这个问题的方法......但到目前为止,没有任何效果。

星期一,我在尝试安装 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"

然后我尝试使用设置选项为 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,我的 gem 环境详细信息如下:

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

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

命令是:

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