Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bundle update not working on an out of sync lockfile #7607

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/rake
Expand Up @@ -3,7 +3,7 @@

require_relative "../bundler/spec/support/rubygems_ext"

if ["dev:deps", "dev:frozen_deps", "spec:deps", "spec:parallel_deps"].include?(ARGV[0])
if ["setup", "dev:deps", "dev:frozen_deps", "spec:deps", "spec:parallel_deps"].include?(ARGV[0])
deivid-rodriguez marked this conversation as resolved.
Show resolved Hide resolved
Spec::Rubygems.gem_load_and_possibly_install("rake", "rake")
else
Spec::Rubygems.gem_load("rake", "rake")
Expand Down
8 changes: 4 additions & 4 deletions bundler/lib/bundler/definition.rb
Expand Up @@ -92,11 +92,12 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
@platforms = @locked_platforms.dup
@locked_bundler_version = @locked_gems.bundler_version
@locked_ruby_version = @locked_gems.ruby_version
@originally_locked_deps = @locked_gems.dependencies
@originally_locked_specs = SpecSet.new(@locked_gems.specs)
@locked_checksums = @locked_gems.checksums

if unlock != true
@locked_deps = @locked_gems.dependencies
@locked_deps = @originally_locked_deps
@locked_specs = @originally_locked_specs
@locked_sources = @locked_gems.sources
else
Expand All @@ -111,6 +112,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
@locked_gems = nil
@locked_deps = {}
@locked_specs = SpecSet.new([])
@originally_locked_deps = {}
@originally_locked_specs = @locked_specs
@locked_sources = []
@locked_platforms = []
Expand Down Expand Up @@ -835,9 +837,7 @@ def converge_dependencies
dep.source = sources.get(dep.source)
end

next if unlocking?

unless locked_dep = @locked_deps[dep.name]
unless locked_dep = @originally_locked_deps[dep.name]
changes = true
next
end
Expand Down
46 changes: 46 additions & 0 deletions bundler/spec/commands/update_spec.rb
Expand Up @@ -1954,6 +1954,52 @@
end
end

context "when Gemfile dependencies have changed" do
before do
build_repo4 do
build_gem "nokogiri", "1.16.4" do |s|
s.platform = "arm64-darwin"
end

build_gem "nokogiri", "1.16.4" do |s|
s.platform = "x86_64-linux"
end

build_gem "prism", "0.25.0"
end

gemfile <<~G
source "#{file_uri_for(gem_repo4)}"
gem "nokogiri", ">=1.16.4"
gem "prism", ">=0.25.0"
G

lockfile <<~L
GEM
remote: #{file_uri_for(gem_repo4)}/
specs:
nokogiri (1.16.4-arm64-darwin)
nokogiri (1.16.4-x86_64-linux)

PLATFORMS
arm64-darwin
x86_64-linux

DEPENDENCIES
nokogiri (>= 1.16.4)

BUNDLED WITH
#{Bundler::VERSION}
L
end

it "still works" do
simulate_platform "arm64-darwin-23" do
bundle "update"
end
end
end

context "error handling" do
before do
gemfile "source \"#{file_uri_for(gem_repo1)}\""
Expand Down