[rubygems/rubygems] Print a better debug message when lockfile does not include the current platform

https://github.com/rubygems/rubygems/commit/afb7a6d754
This commit is contained in:
David Rodríguez 2024-07-25 18:56:53 +02:00 committed by git
parent 997642cfbd
commit 0dda30d9eb
2 changed files with 39 additions and 7 deletions

View File

@ -137,7 +137,7 @@ module Bundler
end
@unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
add_current_platform unless Bundler.frozen_bundle?
@current_platform_missing = add_current_platform unless Bundler.frozen_bundle?
converge_path_sources_to_gemspec_sources
@path_changes = converge_paths
@ -484,6 +484,7 @@ module Bundler
!@source_changes &&
!@dependency_changes &&
!@current_platform_missing &&
@new_platforms.empty? &&
!@path_changes &&
!@local_changes &&
@ -676,7 +677,8 @@ module Bundler
@most_specific_non_local_locked_ruby_platform = find_most_specific_locked_ruby_platform
return if @most_specific_non_local_locked_ruby_platform
add_platform(local_platform)
@platforms << local_platform
true
end
def find_most_specific_locked_ruby_platform
@ -704,6 +706,7 @@ module Bundler
[
[@source_changes, "the list of sources changed"],
[@dependency_changes, "the dependencies in your gemfile changed"],
[@current_platform_missing, "your lockfile does not include the current platform"],
[@new_platforms.any?, "you added a new platform to your gemfile"],
[@path_changes, "the gemspecs for path gems changed"],
[@local_changes, "the gemspecs for git local gems changed"],

View File

@ -1136,12 +1136,16 @@ RSpec.describe "bundle install with gem sources" do
end
end
context "in a frozen bundle" do
before do
context "when current platform not included in the lockfile" do
around do |example|
build_repo4 do
build_gem "libv8", "8.4.255.0" do |s|
s.platform = "x86_64-darwin-19"
end
build_gem "libv8", "8.4.255.0" do |s|
s.platform = "x86_64-linux"
end
end
gemfile <<-G
@ -1166,11 +1170,36 @@ RSpec.describe "bundle install with gem sources" do
#{Bundler::VERSION}
L
bundle "config set --local deployment true"
simulate_platform("x86_64-linux", &example)
end
it "should fail loudly if the lockfile platforms don't include the current platform" do
simulate_platform("x86_64-linux") { bundle "install", raise_on_error: false }
it "adds the current platform to the lockfile" do
bundle "install --verbose"
expect(out).to include("re-resolving dependencies because your lockfile does not include the current platform")
expect(lockfile).to eq <<~L
GEM
remote: https://gem.repo4/
specs:
libv8 (8.4.255.0-x86_64-darwin-19)
libv8 (8.4.255.0-x86_64-linux)
PLATFORMS
x86_64-darwin-19
x86_64-linux
DEPENDENCIES
libv8
BUNDLED WITH
#{Bundler::VERSION}
L
end
it "fails loudly if frozen mode set" do
bundle "config set --local deployment true"
bundle "install", raise_on_error: false
expect(err).to eq(
"Your bundle only supports platforms [\"x86_64-darwin-19\"] but your local platform is x86_64-linux. " \