From 0fcb4c6af72a5fe4222a705e161dc0b42d135fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 30 Jun 2023 11:52:11 +0200 Subject: [rubygems/rubygems] Fix another incorrect removal of "ruby" platform from lockfile When dependencies in path sources have changed, we'll be re-resolving, and we can't really know whether the resolution will be valid or invalid for the Ruby platform, so skip the removal in that case. https://github.com/rubygems/rubygems/commit/afc3b0956f --- lib/bundler/definition.rb | 1 + spec/bundler/install/gemfile/path_spec.rb | 46 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 070543575d..d7246dadf0 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -941,6 +941,7 @@ module Bundler Bundler.local_platform == Gem::Platform::RUBY || !platforms.include?(Gem::Platform::RUBY) || (@new_platform && platforms.last == Gem::Platform::RUBY) || + @path_changes || @dependency_changes || !@originally_locked_specs.incomplete_ruby_specs?(dependencies) diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb index 9ef1c879f8..a5207036c3 100644 --- a/spec/bundler/install/gemfile/path_spec.rb +++ b/spec/bundler/install/gemfile/path_spec.rb @@ -782,6 +782,52 @@ RSpec.describe "bundle install with explicit source paths" do expect(the_bundle).to include_gems "rack 0.9.1" end + + it "does not remove existing ruby platform" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack", "0.9.1" + end + + lockfile <<~L + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + + PLATFORMS + #{lockfile_platforms("ruby")} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "lock" + + expect(lockfile).to eq <<~G + PATH + remote: #{lib_path("foo")} + specs: + foo (1.0) + rack (= 0.9.1) + + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + rack (0.9.1) + + PLATFORMS + #{lockfile_platforms("ruby")} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + G + end end describe "switching sources" do -- cgit v1.2.3