diff --git a/Library/Homebrew/resource_auditor.rb b/Library/Homebrew/resource_auditor.rb index 85fdb79d0f..fe07821a8d 100644 --- a/Library/Homebrew/resource_auditor.rb +++ b/Library/Homebrew/resource_auditor.rb @@ -149,7 +149,13 @@ module Homebrew problem http_content_problem end elsif strategy <= GitDownloadStrategy - problem "The URL #{url} is not a valid git URL" unless Utils::Git.remote_exists? url + attempts = 0 + remote_exists = T.let(false, T::Boolean) + while !remote_exists && attempts < Homebrew::EnvConfig.curl_retries.to_i + remote_exists = Utils::Git.remote_exists?(url) + attempts += 1 + end + problem "The URL #{url} is not a valid git URL" unless remote_exists elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? next unless Utils::Svn.available? diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 7b3aba4b7a..6a67b98b91 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -298,9 +298,10 @@ module Utils end details = T.let(nil, T.nilable(T::Hash[Symbol, T.untyped])) + attempts = 0 user_agents.each do |user_agent| - details = - curl_http_content_headers_and_checksum( + loop do + details = curl_http_content_headers_and_checksum( url, specs: specs, hash_needed: hash_needed, @@ -308,6 +309,14 @@ module Utils user_agent: user_agent, referer: referer, ) + + # Retry on network issues + break if details[:exit_status] != 52 && details[:exit_status] != 56 + + attempts += 1 + break if attempts >= Homebrew::EnvConfig.curl_retries.to_i + end + break if http_status_ok?(details[:status_code]) end @@ -453,6 +462,7 @@ module Utils { url: url, final_url: final_url, + exit_status: status.exitstatus, status_code: status_code, headers: headers, etag: etag,