lib/bundler/source/rubygems.rb in bundler-2.3.17 vs lib/bundler/source/rubygems.rb in bundler-2.3.18

- old
+ new

@@ -151,17 +151,15 @@ if spec.remote # Check for this spec from other sources uris = [spec.remote, *remotes_for_spec(spec)].map(&:anonymized_uri).uniq Installer.ambiguous_gems << [spec.name, *uris] if uris.length > 1 - - path = fetch_gem(spec, options[:previous_spec]) - else - path = cached_gem(spec) - raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path end + path = fetch_gem_if_possible(spec, options[:previous_spec]) + raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path + return if Bundler.settings[:no_install] if requires_sudo? install_path = Bundler.tmp(spec.full_name) bin_path = install_path.join("bin") @@ -240,11 +238,11 @@ ensure Bundler.rm_rf(install_path) if requires_sudo? end def cache(spec, custom_path = nil) - cached_path = cached_gem(spec) + cached_path = Bundler.settings[:cache_all_platforms] ? fetch_gem_if_possible(spec) : cached_gem(spec) raise GemNotFound, "Missing gem file '#{spec.file_name}'." unless cached_path return if File.dirname(cached_path) == Bundler.app_cache.to_s Bundler.ui.info " * #{File.basename(cached_path)}" FileUtils.cp(cached_path, Bundler.app_cache(custom_path)) rescue Errno::EACCES => e @@ -457,9 +455,17 @@ Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over else Bundler.ui.info "Fetching source index from #{URICredentialsFilter.credential_filtered_uri(f.uri)}" index.use f.specs_with_retry(nil, self), override_dupes end + end + end + + def fetch_gem_if_possible(spec, previous_spec = nil) + if spec.remote + fetch_gem(spec, previous_spec) + else + cached_gem(spec) end end def fetch_gem(spec, previous_spec = nil) spec.fetch_platform