aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler/lazy_specification.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/lazy_specification.rb')
-rw-r--r--lib/bundler/lazy_specification.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index dccfe48bba..6749892930 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -89,7 +89,7 @@ module Bundler
installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
- specification = __materialize__(installable_candidates)
+ specification = __materialize__(installable_candidates, :fallback_to_non_installable => false)
return specification unless specification.nil?
if target_platform != platform
@@ -102,13 +102,18 @@ module Bundler
__materialize__(candidates)
end
- def __materialize__(candidates)
+ # If in frozen mode, we fallback to a non-installable candidate because by
+ # doing this we avoid re-resolving and potentially end up changing the
+ # lock file, which is not allowed. In that case, we will give a proper error
+ # about the mismatch higher up the stack, right before trying to install the
+ # bad gem.
+ def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
search = candidates.reverse.find do |spec|
spec.is_a?(StubSpecification) ||
(spec.matches_current_ruby? &&
spec.matches_current_rubygems?)
end
- if search.nil? && Bundler.frozen_bundle?
+ if search.nil? && fallback_to_non_installable
search = candidates.last
else
search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))