ruby-changes:64173
From: Hiroshi <ko1@a...>
Date: Tue, 15 Dec 2020 10:54:30 +0900 (JST)
Subject: [ruby-changes:64173] 2fa9f3c032 (master): Prepare to release rubygems-3.2.1 and bundler-2.2.1
https://git.ruby-lang.org/ruby.git/commit/?id=2fa9f3c032 From 2fa9f3c0322570dfb1672b49bc1f3306ef595131 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Tue, 15 Dec 2020 08:32:54 +0900 Subject: Prepare to release rubygems-3.2.1 and bundler-2.2.1 diff --git a/lib/bundler.rb b/lib/bundler.rb index 0ddd2c7..7a01de5 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -212,6 +212,15 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L212 end end + def locked_bundler_version + return nil unless defined?(@definition) && @definition + + locked_gems = definition.locked_gems + return nil unless locked_gems + + locked_gems.bundler_version + end + def ruby_scope "#{Bundler.rubygems.ruby_engine}/#{RbConfig::CONFIG["ruby_version"]}" end @@ -602,8 +611,9 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L611 reset_rubygems! end - def reset_settings! + def reset_settings_and_root! @settings = nil + @root = nil end def reset_paths! diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index e2dceb9..2f495d4 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -57,7 +57,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L57 custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile] if custom_gemfile && !custom_gemfile.empty? Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile) - Bundler.reset_settings! + Bundler.reset_settings_and_root! end Bundler.settings.set_command_option_if_given :retry, options[:retry] diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index b8d9be2..6a1789e 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -76,6 +76,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/outdated.rb#L76 next unless gems.empty? || gems.include?(current_spec.name) active_spec = retrieve_active_spec(definition, current_spec) + next unless active_spec + next unless filter_options_patch.empty? || update_present_via_semver_portions(current_spec, active_spec, options) gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version) @@ -229,8 +231,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/outdated.rb#L231 end def update_present_via_semver_portions(current_spec, active_spec, options) - return false if active_spec.nil? - current_major = current_spec.version.segments.first active_major = active_spec.version.segments.first diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 4cf4f76..fdd093f 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -269,7 +269,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L269 else # Run a resolve against the locally available gems Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}") - last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms) + platforms_for_resolve = platforms.one? {|p| generic(p) == Gem::Platform::RUBY } ? platforms : platforms.reject{|p| p == Gem::Platform::RUBY } + expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote, platforms_for_resolve.map {|p| generic(p) }) + last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms_for_resolve) end # filter out gems that _can_ be installed on multiple platforms, but don't need @@ -548,11 +550,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L550 private def add_current_platform - current_platforms.each {|platform| add_platform(platform) } - end - - def current_platforms - [local_platform, generic_local_platform].uniq + add_platform(local_platform) end def change_reason @@ -847,14 +845,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L845 @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) } end - # This list of dependencies is only used in #resolve, so it's OK to add - # the metadata dependencies here - def expanded_dependencies - @expanded_dependencies ||= begin - expand_dependencies(dependencies + metadata_dependencies, @remote) - end - end - def metadata_dependencies @metadata_dependencies ||= begin ruby_versions = ruby_version_requirements(@ruby_version) @@ -881,7 +871,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L871 end end - def expand_dependencies(dependencies, remote = false) + def expand_dependencies(dependencies, remote = false, platforms = nil) + platforms ||= @platforms deps = [] dependencies.each do |dep| dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index 26e5f3d..af07e8b 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -96,9 +96,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L96 def gem_platforms(valid_platforms) return valid_platforms if @platforms.empty? + valid_generic_platforms = valid_platforms.map {|p| [p, GemHelpers.generic(p)] }.to_h @gem_platforms ||= expanded_platforms.compact.uniq - valid_platforms & @gem_platforms + filtered_generic_platforms = valid_generic_platforms.values & @gem_platforms + valid_generic_platforms.select {|_, v| filtered_generic_platforms.include?(v) }.keys end def expanded_platforms diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 22bf0f3..7b1d28b 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -82,7 +82,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lazy_specification.rb#L82 search_object = if source.is_a?(Source::Path) Dependency.new(name, version) else - self + ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version) end platform_object = Gem::Platform.new(platform) candidates = source.specs.search(search_object) @@ -129,5 +129,19 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lazy_specification.rb#L129 @specification.send(method, *args, &blk) end + + # + # Bundler 2.2.0 was the first version that records the full resolution + # including platform specific gems in the lockfile, which means that if a + # gem with RUBY platform is recorded, the RUBY platform version of the gem + # should be installed. Previously bundler would record only generic versions + # in the lockfile and then install the most specific platform variant if + # available. + # + def ruby_platform_materializes_to_ruby_platform? + locked_bundler_version = Bundler.locked_bundler_version + + locked_bundler_version.nil? || Gem::Version.new(locked_bundler_version) >= Gem::Version.new("2.2.0") + end end end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 327c170..4bbcbd1 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -75,7 +75,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/resolver.rb#L75 return unless debug? debug_info = yield debug_info = debug_info.inspect unless debug_info.is_a?(String) - warn debug_info.split("\n").map {|s| "BUNDLER: " + " " * depth + s } + puts debug_info.split("\n").map {|s| "BUNDLER: " + " " * depth + s } end def debug? @@ -106,18 +106,19 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/resolver.rb#L106 specification.dependencies_for_activated_platforms end - def search_for(dependency) - platform = dependency.__platform - dependency = dependency.dep unless dependency.is_a? Gem::Dependency - search = @search_for[dependency] ||= begin + def search_for(dependency_proxy) + platform = dependency_proxy.__platform + dependency = dependency_proxy.dep + @search_for[dependency_proxy] ||= begin + name = dependency.name index = index_for(dependency) - results = index.search(dependency, @base[dependency.name]) + results = index.search(dependency, @base[name]) - if vertex = @base_dg.vertex_named(dependency.name) + if vertex = @base_dg.vertex_named(name) locked_requirement = vertex.payload.requirement end - if !@prerelease_specified[dependency.name] && (!@use_gvp || locked_requirement.nil?) + if !@prerelease_specified[name] && (!@use_gvp || locked_requirement.nil?) # Move prereleases to the beginning of the list, so they're considered # last during resolution. pre, results = results.partition {|spec| spec.version.prerelease? } @@ -145,31 +146,25 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/resolver.rb#L146 end # GVP handles major itself, but it's still a bit risky to trust it with it # until we get it settled with new behavior. For 2.x it can take over all cases. - if !@use_gvp + search = if !@use_gvp spec_groups else @gem_version_promoter.sort_versions(dependency, spec_groups) end - end - s (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/