在运行bundle install

时间:2017-02-20 22:50:18

标签: ruby-on-rails ruby error-handling bundler

我正在开发一个gem来构建一个具有各种依赖关系的新Rails应用程序。运行bundle install时,我会定期点击此错误:

Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/<gem_name>.gem)
An error occurred while installing <gem_name> (x.x.x), and Bundler cannot continue.
Make sure that `gem install <gem_name> -v 'x.x.x'` succeeds before bundling.

如果我只是新建一个Rails应用程序并点击这个,那么错误很容易通过运行bundle install几次直到所有安装都没有失败来解决,但是,在生成器gem中,我需要能够捕获此错误并重试bundle install。我希望有一些事情能够发挥作用,但事实并非如此:

begin
  run 'bundle install'
rescue Errno::ECONNRESET => e
  puts "Retrying... Error caught: #{e}"
  count += 1
  retry unless count > 10
  puts "Tried to `bundle install` 10 times: #{e}"
end

帮助?

0 个答案:

没有答案