Skip to content

Commit 9aca2b5

Browse files
Merge pull request #7659 from rubygems/deivid-rodriguez/fix-materialized-for-all-platforms-regression
Fix regression when caching gems from secondary sources (cherry picked from commit 3fb1c37)
1 parent 69c86ed commit 9aca2b5

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

bundler/lib/bundler/spec_set.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def materialize(deps)
129129
def materialized_for_all_platforms
130130
@specs.map do |s|
131131
next s unless s.is_a?(LazySpecification)
132+
s.source.cached!
132133
s.source.remote!
133134
spec = s.materialize_for_installation
134135
raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec

bundler/spec/commands/cache_spec.rb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,66 @@
386386
expect(the_bundle).to include_gems "rack 1.0.0"
387387
end
388388

389+
it "uses cached gems for secondary sources when cache_all_platforms configured" do
390+
build_repo4 do
391+
build_gem "foo", "1.0.0" do |s|
392+
s.platform = "x86_64-linux"
393+
end
394+
395+
build_gem "foo", "1.0.0" do |s|
396+
s.platform = "arm64-darwin"
397+
end
398+
end
399+
400+
gemfile <<~G
401+
source "https://gems.repo2"
402+
403+
source "https://gems.repo4" do
404+
gem "foo"
405+
end
406+
G
407+
408+
lockfile <<~L
409+
GEM
410+
remote: https://gems.repo2/
411+
specs:
412+
413+
GEM
414+
remote: https://gems.repo4/
415+
specs:
416+
foo (1.0.0-x86_64-linux)
417+
foo (1.0.0-arm64-darwin)
418+
419+
PLATFORMS
420+
arm64-darwin
421+
ruby
422+
x86_64-linux
423+
424+
DEPENDENCIES
425+
foo
426+
427+
BUNDLED WITH
428+
#{Bundler::VERSION}
429+
L
430+
431+
simulate_platform "x86_64-linux" do
432+
bundle "config set cache_all_platforms true"
433+
bundle "config set path vendor/bundle"
434+
bundle :cache, artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
435+
436+
build_repo4 do
437+
# simulate removal of all remote gems
438+
end
439+
440+
# delete compact index cache
441+
FileUtils.rm_rf home(".bundle/cache/compact_index")
442+
443+
bundle "install", artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
444+
445+
expect(the_bundle).to include_gems "foo 1.0.0 x86_64-linux"
446+
end
447+
end
448+
389449
it "does not reinstall already-installed gems" do
390450
install_gemfile <<-G
391451
source "#{file_uri_for(gem_repo1)}"

0 commit comments

Comments
 (0)