Skip to content

Commit

Permalink
Merge pull request #6784 from rubygems/another-incorrect-ruby-platfor…
Browse files Browse the repository at this point in the history
…m-removal

Fix another incorrect removal of "ruby" platform from lockfile when changing path sources

(cherry picked from commit 84b288c)
  • Loading branch information
simi authored and deivid-rodriguez committed Jul 6, 2023
1 parent f9f0634 commit 0b5765e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions bundler/lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ def remove_ruby_from_platforms_if_necessary!(dependencies)
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)

Expand Down
46 changes: 46 additions & 0 deletions bundler/spec/install/gemfile/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,52 @@

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
Expand Down

0 comments on commit 0b5765e

Please sign in to comment.