Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions bundler/lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ def locked_dependencies
@locked_deps.values
end

def new_deps
@new_deps ||= @dependencies - locked_dependencies
end

def deleted_deps
@deleted_deps ||= locked_dependencies - @dependencies
end

def specs_for(groups)
return specs if groups.empty?
deps = dependencies_for(groups)
Expand All @@ -259,8 +267,17 @@ def resolve
Bundler.ui.debug "Frozen, using resolution from the lockfile"
@locked_specs
elsif !unlocking? && nothing_changed?
Bundler.ui.debug("Found no changes, using resolution from the lockfile")
SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
if deleted_deps.any?
Bundler.ui.debug("Some dependencies were deleted, using a subset of the resolution from the lockfile")
SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
else
Bundler.ui.debug("Found no changes, using resolution from the lockfile")
if @locked_gems.may_include_redundant_platform_specific_gems?
SpecSet.new(filter_specs(@locked_specs, @dependencies))
else
@locked_specs
end
end
else
last_resolve = converge_locked_specs
# Run a resolve against the locally available gems
Expand Down Expand Up @@ -359,9 +376,6 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
added.concat new_platforms.map {|p| "* platform: #{p}" }
deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }

new_deps = @dependencies - locked_dependencies
deleted_deps = locked_dependencies - @dependencies

added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?

Expand Down
4 changes: 4 additions & 0 deletions bundler/lib/bundler/lockfile_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def initialize(lockfile)
"and then `bundle install` to generate a new lockfile."
end

def may_include_redundant_platform_specific_gems?
bundler_version.nil? || bundler_version < Gem::Version.new("1.16.2")
end

private

TYPES = {
Expand Down
12 changes: 6 additions & 6 deletions bundler/spec/install/gemfile/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,28 @@
pry

BUNDLED WITH
#{Bundler::VERSION}
1.16.1
L

aggregate_failures do
lockfile bad_lockfile
bundle :install
bundle :install, :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(lockfile).to eq good_lockfile

lockfile bad_lockfile
bundle :update, :all => true
bundle :update, :all => true, :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(lockfile).to eq good_lockfile

lockfile bad_lockfile
bundle "update ffi"
bundle "update ffi", :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(lockfile).to eq good_lockfile

lockfile bad_lockfile
bundle "update empyrean"
bundle "update empyrean", :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(lockfile).to eq good_lockfile

lockfile bad_lockfile
bundle :lock
bundle :lock, :env => { "BUNDLER_VERSION" => Bundler::VERSION }
expect(lockfile).to eq good_lockfile
end
end
Expand Down
16 changes: 16 additions & 0 deletions bundler/spec/runtime/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,22 @@ def clean_load_path(lp)
expect(err).to be_empty
end

it "doesn't re-resolve when deleting dependencies" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
gem "actionpack"
G

install_gemfile <<-G, :verbose => true
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G

expect(out).to include("Some dependencies were deleted, using a subset of the resolution from the lockfile")
expect(err).to be_empty
end

it "remembers --without and does not include groups passed to Bundler.setup" do
bundle "config set --local without rails"
install_gemfile <<-G
Expand Down