diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index a083247adc4..d933907741b 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -274,10 +274,16 @@ def build_gem(gem_dir, spec) build(spec) end + RUBYGEMS_DOWNLOAD_ERRORS = [ + Gem::RemoteFetcher::FetchError, + ].freeze + def download_gem(spec, uri, path) uri = Bundler.settings.mirror_for(uri) fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy]) - fetcher.download(spec, uri, path) + Bundler::Retry.new("download gem #{uri}", RUBYGEMS_DOWNLOAD_ERRORS).attempts do + fetcher.download(spec, uri, path) + end end def security_policy_keys