Skip to main content

Ruby Source


Error

这个错误表明在与gems.ruby-china.com服务器通信时发生了网络连接问题

Retrying dependency api due to error (2/4): Bundler::HTTPError Network error
too many connection resets (due to connection reset by peer - Errno::ECONNRESET)

换源

官方源

gem sources --add https://rubygems.org/ --remove https://gems.ruby-china.com/

清华源

gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://gems.ruby-china.com/

清除本地缓存

bundle clean --force

增加重试次数

bundle install --retry=5

优化 bundle install

如果你的网络不稳定,可以:

使用国内镜像加速:

bundle config mirror.https://rubygems.org https://gems.ruby-china.com
bundle install --retry=

手动指定源(在 Gemfile 里):

source 'https://gems.ruby-china.com'

增加 -jobs 参数(并行下载):

bundle install --jobs=4 --retry=5
  • -jobs=4:并行下载 4 个 gem,加速安装。
  • -retry=5:失败时最多重试 5 次。