summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/lazy_specification.rb64
1 files changed, 32 insertions, 32 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index e3089f230f..ba48f2e89e 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -127,7 +127,7 @@ module Bundler
matching_specs = source.specs.search(self)
return self if matching_specs.empty?
- __materialize__(matching_specs)
+ choose_compatible(matching_specs)
end
def materialized_for_installation
@@ -149,46 +149,17 @@ module Bundler
installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
- specification = __materialize__(installable_candidates, fallback_to_non_installable: false)
+ specification = choose_compatible(installable_candidates, fallback_to_non_installable: false)
return specification unless specification.nil?
if target_platform != platform
installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)
end
- __materialize__(installable_candidates)
+ choose_compatible(installable_candidates)
end
end
- # 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_metadata?
- end
- if search.nil? && fallback_to_non_installable
- search = candidates.last
- elsif search && search.full_name == full_name
- # We don't validate locally installed dependencies but accept what's in
- # the lockfile instead for performance, since loading locally installed
- # dependencies would mean evaluating all gemspecs, which would affect
- # `bundler/setup` performance
- if search.is_a?(StubSpecification)
- search.dependencies = dependencies
- else
- if !source.is_a?(Source::Path) && search.runtime_dependencies.sort != dependencies.sort
- raise IncorrectLockfileDependencies.new(self)
- end
-
- search.locked_platform = platform if search.instance_of?(RemoteSpecification) || search.instance_of?(EndpointSpecification)
- end
- end
- search
- end
-
def inspect
"#<#{self.class} @name=\"#{name}\" (#{full_name.delete_prefix("#{name}-")})>"
end
@@ -217,5 +188,34 @@ module Bundler
(most_specific_locked_platform != generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
end
+
+ # 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 choose_compatible(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
+ search = candidates.reverse.find do |spec|
+ spec.is_a?(StubSpecification) || spec.matches_current_metadata?
+ end
+ if search.nil? && fallback_to_non_installable
+ search = candidates.last
+ elsif search && search.full_name == full_name
+ # We don't validate locally installed dependencies but accept what's in
+ # the lockfile instead for performance, since loading locally installed
+ # dependencies would mean evaluating all gemspecs, which would affect
+ # `bundler/setup` performance
+ if search.is_a?(StubSpecification)
+ search.dependencies = dependencies
+ else
+ if !source.is_a?(Source::Path) && search.runtime_dependencies.sort != dependencies.sort
+ raise IncorrectLockfileDependencies.new(self)
+ end
+
+ search.locked_platform = platform if search.instance_of?(RemoteSpecification) || search.instance_of?(EndpointSpecification)
+ end
+ end
+ search
+ end
end
end