diff options
-rw-r--r-- | lib/bundler/resolver.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/lock_spec.rb | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index c17086ea78..adc379e1e3 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -299,7 +299,7 @@ module Bundler end def filter_prereleases(specs, package) - return specs unless package.ignores_prereleases? + return specs unless package.ignores_prereleases? && specs.size > 1 specs.reject {|s| s.version.prerelease? } end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 160a17bf55..59a74b3083 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -998,6 +998,31 @@ RSpec.describe "bundle lock" do expect(lockfile).to include("autobuild (1.10.1)") end + # Newer rails depends on Bundler, while ancient Rails does not. Bundler tries + # a first resolution pass that does not consider pre-releases. However, when + # using a pre-release Bundler (like the .dev version), that results in that + # pre-release being ignored and resolving to a version that does not depend on + # Bundler at all. We should avoid that and still consider .dev Bundler. + # + it "does not ignore prereleases with there's only one candidate" do + build_repo4 do + build_gem "rails", "7.4.0.2" do |s| + s.add_dependency "bundler", ">= 1.15.0" + end + + build_gem "rails", "2.3.18" + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + gem "rails" + G + + bundle "lock" + expect(lockfile).to_not include("rails (2.3.18)") + expect(lockfile).to include("rails (7.4.0.2)") + end + it "deals with platform specific incompatibilities" do build_repo4 do build_gem "activerecord", "6.0.6" |