diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index df87358ac8..e668ac7953 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -984,8 +984,9 @@ module Bundler @locked_gems.specs.reduce({}) do |requirements, locked_spec| name = locked_spec.name dependency = dependencies_by_name[name] + next requirements unless dependency next requirements if @locked_gems.dependencies[name] != dependency - next requirements if dependency && dependency.source.is_a?(Source::Path) + next requirements if dependency.source.is_a?(Source::Path) dep = Gem::Dependency.new(name, ">= #{locked_spec.version}") requirements[name] = DepProxy.new(dep, locked_spec.platform) requirements diff --git a/spec/bundler/install/bundler_spec.rb b/spec/bundler/install/bundler_spec.rb index 7c9b1a016d..5e15333ad8 100644 --- a/spec/bundler/install/bundler_spec.rb +++ b/spec/bundler/install/bundler_spec.rb @@ -131,6 +131,21 @@ RSpec.describe "bundle install" do expect(err).to include(nice_error) end + it "does not cause a conflict if new dependencies in the Gemfile require older dependencies than the lockfile" do + install_gemfile! <<-G + source "#{file_uri_for(gem_repo2)}" + gem 'rails', "2.3.2" + G + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "rails_fail" + G + + expect(out).to include("Installing activesupport 1.2.3 (was 2.3.2)") + expect(err).to be_empty + end + it "can install dependencies with newer bundler version with system gems" do bundle! "config set path.system true"