From 34c6f6790f9316a816f27129a343cb9b7eb6e862 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Thu, 5 Oct 2023 16:14:35 -0600 Subject: [PATCH] fix silently removing non-local-platform gems (#7) --- lib/bundler/multilock.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/bundler/multilock.rb b/lib/bundler/multilock.rb index d8782a7..c93d762 100644 --- a/lib/bundler/multilock.rb +++ b/lib/bundler/multilock.rb @@ -432,6 +432,18 @@ def write_lockfile(lockfile_definition, lockfile, install:, dependency_changes: previous_ui_level = Bundler.ui.level Bundler.ui.level = "warn" begin + # this is a horrible hack, to fix what I consider to be a Bundler bug. + # basically, if you have multiple platform specific gems in your + # lockfile, and that gem gets unlocked, Bundler will only search + # locally to find them. But non-platform-local gems are _never_ + # installed locally. So just find the non-platform-local gems + # in the lockfile (that we know are there from a prior remote + # resolution), and add them to the locally installed spec list. + definition.send(:source_map).locked_specs.each do |spec| + next if spec.match_platform(Bundler.local_platform) + + spec.source.specs.add(spec) + end definition.resolve_with_cache! rescue GemNotFound, SolveFailure definition = orig_definition