ruby-changes:70939
From: David <ko1@a...>
Date: Wed, 19 Jan 2022 11:21:06 +0900 (JST)
Subject: [ruby-changes:70939] e7249294fb (master): [rubygems/rubygems] Fix regression with old marshaled specs having null required_rubygems_version
https://git.ruby-lang.org/ruby.git/commit/?id=e7249294fb From e7249294fb85953c3caa0af1eb9d3627a4827a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Mon, 17 Jan 2022 18:55:10 +0100 Subject: [rubygems/rubygems] Fix regression with old marshaled specs having null required_rubygems_version https://github.com/rubygems/rubygems/commit/91f07a0208 --- lib/bundler/remote_specification.rb | 7 ++++ spec/bundler/install/gemfile/sources_spec.rb | 53 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index 89b69e1045e..4e966b820aa 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -27,6 +27,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/remote_specification.rb#L27 @platform = _remote_specification.platform end + # A fallback is included because the original version of the specification + # API didn't include that field, so some marshalled specs in the index have it + # set to +nil+. + def required_rubygems_version + @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default + end + def full_name if platform == Gem::Platform::RUBY || platform.nil? "#{@name}-#{@version}" diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb index 5456e95f33d..26ecb840c73 100644 --- a/spec/bundler/install/gemfile/sources_spec.rb +++ b/spec/bundler/install/gemfile/sources_spec.rb @@ -1443,4 +1443,57 @@ RSpec.describe "bundle install with gems on multiple sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/sources_spec.rb#L1443 L end end + + context "when default source includes old gems with nil required_rubygems_version" do + before do + build_repo2 do + build_gem "ruport", "1.7.0.3" do |s| + s.add_dependency "pdf-writer", "1.1.8" + end + end + + build_repo gem_repo4 do + build_gem "pdf-writer", "1.1.8" + end + + path = "#{gem_repo4}/#{Gem::MARSHAL_SPEC_DIR}/pdf-writer-1.1.8.gemspec.rz" + spec = Marshal.load(Bundler.rubygems.inflate(File.binread(path))) + spec.instance_variable_set(:@required_rubygems_version, nil) + File.open(path, "wb") do |f| + f.write Gem.deflate(Marshal.dump(spec)) + end + + gemfile <<~G + source "https://localgemserver.test" + + gem "ruport", "= 1.7.0.3", :source => "https://localgemserver.test/extra" + G + end + + it "handles that fine" do + bundle "install", :artifice => "compact_index_extra", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + + expect(lockfile).to eq <<~L + GEM + remote: https://localgemserver.test/ + specs: + pdf-writer (1.1.8) + + GEM + remote: https://localgemserver.test/extra/ + specs: + ruport (1.7.0.3) + pdf-writer (= 1.1.8) + + PLATFORMS + #{specific_local_platform} + + DEPENDENCIES + ruport (= 1.7.0.3)! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + end end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/