mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Account for default gems not having remote when caching
https://github.com/rubygems/rubygems/commit/b93d4de2ff
This commit is contained in:
parent
9101269e94
commit
7b78aba53a
2 changed files with 24 additions and 6 deletions
|
@ -153,13 +153,11 @@ module Bundler
|
|||
# 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?
|
||||
|
@ -242,7 +240,7 @@ module Bundler
|
|||
end
|
||||
|
||||
def cache(spec, custom_path = nil)
|
||||
cached_path = Bundler.settings[:cache_all_platforms] ? fetch_gem(spec) : 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)}"
|
||||
|
@ -462,6 +460,14 @@ module Bundler
|
|||
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
|
||||
|
||||
|
|
12
spec/bundler/cache/gems_spec.rb
vendored
12
spec/bundler/cache/gems_spec.rb
vendored
|
@ -118,6 +118,18 @@ RSpec.describe "bundle cache" do
|
|||
expect(bundled_app("vendor/cache/json-#{default_json_version}.gem")).to exist
|
||||
end
|
||||
|
||||
it "caches builtin gems when cache_all_platforms is set" do
|
||||
gemfile <<-G
|
||||
source "#{file_uri_for(gem_repo2)}"
|
||||
gem "json"
|
||||
G
|
||||
|
||||
bundle "config set cache_all_platforms true"
|
||||
|
||||
bundle :cache
|
||||
expect(bundled_app("vendor/cache/json-#{default_json_version}.gem")).to exist
|
||||
end
|
||||
|
||||
it "doesn't make remote request after caching the gem" do
|
||||
build_gem "builtin_gem_2", "1.0.2", :path => bundled_app("vendor/cache") do |s|
|
||||
s.summary = "This builtin_gem is bundled with Ruby"
|
||||
|
|
Loading…
Reference in a new issue