ERROR: While executing gem … (Gem::RemoteFetcher::FetchError)

原文地址:https://www.zfanw.com/blog/error-while-executing-gem-gem-remote-fetch-error.htmlcss

我对命令行下安装 gem 包或是 npm 包有很大的心理阴影,由于出现没法​安装的几率实在太大了 – 每次都要破口大骂 gfw。html

这一回是在更新 gem 时:nginx

gem update --system 

返回的错误以下:sql

ERROR: While executing gem … (Gem::RemoteFetcher::FetchError)npm

Errno::ETIMEDOUT: Operation timed out – connect(2) for “s3.amazonaws.com” port 443 (https://api.rubygems.org/specs.4.8.gz)api

出现 s3 的地址是由于此前 https://rubygems.org 源地址不行,因此执行了 gem source 添加源库:ruby

gem source --add https://s3.amazonaws.com/production.s3.rubygems.org/ 

如你所见,仍是报错。fetch

查了资料,不巧 StackOverflow 上这个问题提到了 Proxy,我国的国情,不挂代理简直混不下去 IT 业,因此个人 Mac OSX 的代理环境是这样的:url

privoxy(http://localhost:8118) -> sslEdge(http://localhost:100010)全局 

Privoxy 我是用来去除一些广告。且把死马当活马医吧:spa

export http_proxy=http://localhost:8118 export https_proxy=http://localhost:8118 gem update --system 

而后目瞪口呆:

Updating rubygems-update Fetching: rubygems-update-2.4.7.gem (100%) Successfully installed rubygems-update-2.4.7 Parsing documentation for rubygems-update-2.4.7 Installing ri documentation for rubygems-update-2.4.7 Installing darkfish documentation for rubygems-update-2.4.7 Done installing documentation for rubygems-update after 2 seconds Installing RubyGems 2.4.7 RubyGems 2.4.7 installed Parsing documentation for rubygems-2.4.7 Installing ri documentation for rubygems-2.4.7 

居然真是代理的问题。因此我猜测是 iterm2 不支持 socks 代理,所以全局并未生效。而经过 Privoxy 的 HTTP 代理作一次转发,就正常了 – 因此,仍是 gfw 的问题。

相关文章
相关标签/搜索