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

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

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

这一回是在更新 gem 时:

gem update --system

返回的错误如下:

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

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

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

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

如你所见,还是报错。

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

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

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

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 的问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值