ruby-changes:72782
From: David <ko1@a...>
Date: Tue, 2 Aug 2022 16:10:45 +0900 (JST)
Subject: [ruby-changes:72782] 3e4fedca4e (master): [rubygems/rubygems] Preserve the previous behavior of raising an error when in frozen mode
https://git.ruby-lang.org/ruby.git/commit/?id=3e4fedca4e From 3e4fedca4e0b068908137d44bcf5a567cb8445d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Sat, 30 Jul 2022 10:07:45 +0200 Subject: [rubygems/rubygems] Preserve the previous behavior of raising an error when in frozen mode https://github.com/rubygems/rubygems/commit/6e35a6edfe --- lib/bundler/lazy_specification.rb | 6 +- spec/bundler/install/gems/resolving_spec.rb | 87 +++++++++++++++++------------ 2 files changed, 55 insertions(+), 38 deletions(-) diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index a88172d96b..9f75c7bab2 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -108,7 +108,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lazy_specification.rb#L108 (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) && spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version)) end - search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification)) + if search.nil? && Bundler.frozen_bundle? + search = candidates.last + else + search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification)) + end search end end diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index 069fa273b4..9c0d6bfe56 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -241,55 +241,68 @@ RSpec.describe "bundle install with install-time dependencies" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gems/resolving_spec.rb#L241 expect(the_bundle).to include_gems("rack 1.2") end - it "automatically updates lockfile to use the older version" do - build_repo2 do - build_gem "parallel_tests", "3.7.0" do |s| - s.required_ruby_version = ">= #{current_ruby_minor}" - end + context "when there is a lockfile using the newer incompatible version" do + before do + build_repo2 do + build_gem "parallel_tests", "3.7.0" do |s| + s.required_ruby_version = ">= #{current_ruby_minor}" + end - build_gem "parallel_tests", "3.8.0" do |s| - s.required_ruby_version = ">= #{next_ruby_minor}" + build_gem "parallel_tests", "3.8.0" do |s| + s.required_ruby_version = ">= #{next_ruby_minor}" + end end - end - gemfile <<-G - source "http://localgemserver.test/" - gem 'parallel_tests' - G + gemfile <<-G + source "http://localgemserver.test/" + gem 'parallel_tests' + G - lockfile <<~L - GEM - remote: http://localgemserver.test/ - specs: - parallel_tests (3.8.0) + lockfile <<~L + GEM + remote: http://localgemserver.test/ + specs: + parallel_tests (3.8.0) - PLATFORMS - #{lockfile_platforms} + PLATFORMS + #{lockfile_platforms} - DEPENDENCIES - parallel_tests + DEPENDENCIES + parallel_tests - BUNDLED WITH - #{Bundler::VERSION} - L + BUNDLED WITH + #{Bundler::VERSION} + L + end - bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } + it "automatically updates lockfile to use the older version" do + bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } - expect(lockfile).to eq <<~L - GEM - remote: http://localgemserver.test/ - specs: - parallel_tests (3.7.0) + expect(lockfile).to eq <<~L + GEM + remote: http://localgemserver.test/ + specs: + parallel_tests (3.7.0) - PLATFORMS - #{lockfile_platforms} + PLATFORMS + #{lockfile_platforms} - DEPENDENCIES - parallel_tests + DEPENDENCIES + parallel_tests - BUNDLED WITH - #{Bundler::VERSION} - L + BUNDLED WITH + #{Bundler::VERSION} + L + end + + it "gives a meaningful error if we're in frozen mode" do + expect do + bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s, "BUNDLE_FROZEN" => "true" }, :raise_on_error => false + end.not_to change { lockfile } + + expect(err).to include("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}") + expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.") + end end it "gives a meaningful error on ruby version mismatches between dependencies" do -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/