diff options
author | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2019-04-25 02:39:47 +0900 |
---|---|---|
committer | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2019-04-29 17:48:05 +0900 |
commit | 7752d128b7052643395cafb92da484f9559c69b8 (patch) | |
tree | fd9ae0faf332391f926960e4bbebc0294b09647d | |
parent | f4c79f2744081b8a60942642786a79d7e7add6a2 (diff) | |
download | bundler-7752d128b7052643395cafb92da484f9559c69b8.tar.gz |
Fix to update conservatively for gemspec update
Fix https://github.com/bundler/bundler/issues/6967
-rw-r--r-- | lib/bundler/definition.rb | 6 | ||||
-rw-r--r-- | spec/install/gemfile/path_spec.rb | 62 |
2 files changed, 66 insertions, 2 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 506b0620d2..81b362fed6 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -802,8 +802,10 @@ module Bundler deps2 = other.dependencies.select {|d| d.type != :development } runtime_dependencies = s.dependencies.select {|d| d.type != :development } - # If the dependencies of the path source have changed, unlock it - next unless runtime_dependencies.sort == deps2.sort + # If the dependencies of the path source have changed and locked spec can't satisfy new dependencies, unlock it + next unless deps2.sort == runtime_dependencies.sort || deps2.all? {|d| satisfies_locked_spec?(d) } + + s.dependencies.replace(other.dependencies) end converged << s diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index c6856ac974..e80764070c 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -484,6 +484,68 @@ RSpec.describe "bundle install with explicit source paths" do expect(the_bundle).to include_gems "rack 1.0.0" end + + it "keeps using the same version if it's compatible" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack", "0.9.1" + end + + bundle "install" + + expect(the_bundle).to include_gems "rack 0.9.1" + + lockfile_should_be <<-G + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + rack (= 0.9.1) + + GEM + remote: #{URI.parse("file://#{gem_repo1}/")} + specs: + rack (0.9.1) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + G + + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack" + end + + bundle "install" + + lockfile_should_be <<-G + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + rack + + GEM + remote: #{URI.parse("file://#{gem_repo1}/")} + specs: + rack (0.9.1) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + G + + expect(the_bundle).to include_gems "rack 0.9.1" + end end describe "switching sources" do |