From ee03df26bad92abb5397a82be3bc385a9ef69b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 11 Feb 2025 16:25:45 +0100 Subject: [rubygems/rubygems] `--prefer-local` should resolve to latest version if no gems are available locally Filtering out remote specs should only apply where there are locally installed specs. Otherwise they should always be considered. https://github.com/rubygems/rubygems/commit/118f8389a1 --- lib/bundler/resolver.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 56a6c7ac67..ce51056904 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -389,9 +389,18 @@ module Bundler end def filter_remote_specs(specs, package) - return specs unless package.prefer_local? + if package.prefer_local? + local_specs = specs.select {|s| s.is_a?(StubSpecification) } - specs.select {|s| s.is_a?(StubSpecification) } + if local_specs.empty? + package.consider_remote_versions! + specs + else + local_specs + end + else + specs + end end # Ignore versions that depend on themselves incorrectly -- cgit v1.2.3