summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2022-07-13 12:56:36 +0900
committerHiroshi SHIBATA <[email protected]>2022-07-13 14:11:55 +0900
commit437a5ae9d6d60bd1972641167a98204007bd1c0b (patch)
tree79b9ea49442fe896dbd8ef59a8622ea010fb3fb7 /lib
parente3a988a29c2cfa4a7e2e045d82989a7342955be8 (diff)
Merge RubyGems and Bundler master
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6124
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler.rb2
-rw-r--r--lib/bundler/current_ruby.rb2
-rw-r--r--lib/bundler/definition.rb26
-rw-r--r--lib/bundler/dependency.rb8
-rw-r--r--lib/bundler/dsl.rb2
-rw-r--r--lib/bundler/force_platform.rb18
-rw-r--r--lib/bundler/gem_helpers.rb2
-rw-r--r--lib/bundler/index.rb6
-rw-r--r--lib/bundler/lazy_specification.rb14
-rw-r--r--lib/bundler/lockfile_parser.rb4
-rw-r--r--lib/bundler/man/gemfile.526
-rw-r--r--lib/bundler/man/gemfile.5.ronn18
-rw-r--r--lib/bundler/match_platform.rb1
-rw-r--r--lib/bundler/resolver.rb9
-rw-r--r--lib/bundler/resolver/spec_group.rb9
-rw-r--r--lib/bundler/rubygems_ext.rb35
-rw-r--r--lib/bundler/spec_set.rb13
-rw-r--r--lib/rubygems/gem_runner.rb10
-rw-r--r--lib/rubygems/installer.rb2
-rw-r--r--lib/rubygems/platform.rb4
-rw-r--r--lib/rubygems/specification.rb15
21 files changed, 157 insertions, 69 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index c99114ae64..9fb9ce3e82 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -455,7 +455,7 @@ EOF
end
def local_platform
- return Gem::Platform::RUBY if settings[:force_ruby_platform] || Gem.platforms == [Gem::Platform::RUBY]
+ return Gem::Platform::RUBY if settings[:force_ruby_platform]
Gem::Platform.local
end
diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
index 27997982c0..36f26b7ab4 100644
--- a/lib/bundler/current_ruby.rb
+++ b/lib/bundler/current_ruby.rb
@@ -78,7 +78,7 @@ module Bundler
end
def x64_mingw?
- Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
+ Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os.start_with?("mingw") && Bundler.local_platform.cpu == "x64"
end
(KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 2e0f23a402..0580860845 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -235,6 +235,14 @@ module Bundler
@locked_deps.values
end
+ def new_deps
+ @new_deps ||= @dependencies - locked_dependencies
+ end
+
+ def deleted_deps
+ @deleted_deps ||= locked_dependencies - @dependencies
+ end
+
def specs_for(groups)
return specs if groups.empty?
deps = dependencies_for(groups)
@@ -259,8 +267,17 @@ module Bundler
Bundler.ui.debug "Frozen, using resolution from the lockfile"
@locked_specs
elsif !unlocking? && nothing_changed?
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
- SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
+ if deleted_deps.any?
+ Bundler.ui.debug("Some dependencies were deleted, using a subset of the resolution from the lockfile")
+ SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
+ else
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
+ if @locked_gems.may_include_redundant_platform_specific_gems?
+ SpecSet.new(filter_specs(@locked_specs, @dependencies))
+ else
+ @locked_specs
+ end
+ end
else
last_resolve = converge_locked_specs
# Run a resolve against the locally available gems
@@ -359,9 +376,6 @@ module Bundler
added.concat new_platforms.map {|p| "* platform: #{p}" }
deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
- new_deps = @dependencies - locked_dependencies
- deleted_deps = locked_dependencies - @dependencies
-
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
@@ -806,7 +820,7 @@ module Bundler
return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
converge_specs(@originally_locked_specs).map do |locked_spec|
name = locked_spec.name
- dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
+ dep = Dependency.new(name, ">= #{locked_spec.version}")
DepProxy.get_proxy(dep, locked_spec.platform)
end
end
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 018a3182b9..2449cb6411 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -1,13 +1,16 @@
# frozen_string_literal: true
require "rubygems/dependency"
+require_relative "force_platform"
require_relative "shared_helpers"
require_relative "rubygems_ext"
module Bundler
class Dependency < Gem::Dependency
+ include ForcePlatform
+
attr_reader :autorequire
- attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref
+ attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref, :force_ruby_platform
# rubocop:disable Naming/VariableNumber
PLATFORM_MAP = {
@@ -109,6 +112,7 @@ module Bundler
@env = options["env"]
@should_include = options.fetch("should_include", true)
@gemfile = options["gemfile"]
+ @force_ruby_platform = options.fetch("force_ruby_platform", default_force_ruby_platform)
@autorequire = Array(options["require"] || []) if options.key?("require")
end
@@ -122,7 +126,7 @@ module Bundler
end
def expanded_platforms
- @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq
+ @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq
end
def should_include?
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index bfa078046c..8b2d0ac97c 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -16,7 +16,7 @@ module Bundler
VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
- platform platforms type source install_if gemfile].freeze
+ platform platforms type source install_if gemfile force_ruby_platform].freeze
GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
diff --git a/lib/bundler/force_platform.rb b/lib/bundler/force_platform.rb
new file mode 100644
index 0000000000..0648ea9737
--- /dev/null
+++ b/lib/bundler/force_platform.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Bundler
+ module ForcePlatform
+ private
+
+ # The `:force_ruby_platform` value used by dependencies for resolution, and
+ # by locked specifications for materialization is `false` by default, except
+ # for TruffleRuby. TruffleRuby generally needs to force the RUBY platform
+ # variant unless the name is explicitly allowlisted.
+
+ def default_force_ruby_platform
+ return false unless Bundler.current_ruby.truffleruby?
+
+ !Gem::Platform::REUSE_AS_BINARY_ON_TRUFFLERUBY.include?(name)
+ end
+ end
+end
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index 632698482f..6bc4fb4991 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -5,11 +5,13 @@ module Bundler
GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant
GENERICS = [
[Gem::Platform.new("java"), Gem::Platform.new("java")],
+ [Gem::Platform.new("universal-java"), Gem::Platform.new("java")],
[Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")],
[Gem::Platform.new("mswin64"), Gem::Platform.new("mswin64")],
[Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],
[Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
[Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
+ [Gem::Platform.new("x64-mingw-ucrt"), Gem::Platform.new("x64-mingw-ucrt")],
[Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")],
].freeze
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index 8930fca6d0..5bc24fc0b2 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -192,11 +192,7 @@ module Bundler
specs += base if base
found = specs.select do |spec|
next true if spec.source.is_a?(Source::Gemspec)
- if base # allow all platforms when searching from a lockfile
- dependency.matches_spec?(spec)
- else
- dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec)
- end
+ dependency.matches_spec?(spec)
end
found
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 198906b987..89b21efc04 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -1,12 +1,15 @@
# frozen_string_literal: true
+require_relative "force_platform"
require_relative "match_platform"
module Bundler
class LazySpecification
+ include ForcePlatform
include MatchPlatform
attr_reader :name, :version, :dependencies, :platform
+ attr_writer :force_ruby_platform
attr_accessor :source, :remote
def initialize(name, version, platform, source = nil)
@@ -16,6 +19,7 @@ module Bundler
@platform = platform || Gem::Platform::RUBY
@source = source
@specification = nil
+ @force_ruby_platform = nil
end
def full_name
@@ -26,6 +30,12 @@ module Bundler
end
end
+ def force_ruby_platform
+ return @force_ruby_platform unless @force_ruby_platform.nil?
+
+ default_force_ruby_platform
+ end
+
def ==(other)
identifier == other.identifier
end
@@ -84,7 +94,7 @@ module Bundler
else
ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version)
end
- platform_object = Gem::Platform.new(platform)
+ platform_object = ruby_platform_materializes_to_ruby_platform? ? Gem::Platform.new(platform) : Gem::Platform.local
candidates = source.specs.search(search_object)
same_platform_candidates = candidates.select do |spec|
MatchPlatform.platforms_match?(spec.platform, platform_object)
@@ -152,7 +162,7 @@ module Bundler
# explicitly add a more specific platform.
#
def ruby_platform_materializes_to_ruby_platform?
- !Bundler.most_specific_locked_platform?(Gem::Platform::RUBY) || Bundler.settings[:force_ruby_platform]
+ !Bundler.most_specific_locked_platform?(generic_local_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
end
end
end
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index e074cbfc33..64fff4713d 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -93,6 +93,10 @@ module Bundler
"and then `bundle install` to generate a new lockfile."
end
+ def may_include_redundant_platform_specific_gems?
+ bundler_version.nil? || bundler_version < Gem::Version.new("1.16.2")
+ end
+
private
TYPES = {
diff --git a/lib/bundler/man/gemfile.5 b/lib/bundler/man/gemfile.5
index eaef7c99be..bf1b8b1c74 100644
--- a/lib/bundler/man/gemfile.5
+++ b/lib/bundler/man/gemfile.5
@@ -331,6 +331,30 @@ gem "nokogiri", platforms: [:mri_18, :jruby]
.P
All operations involving groups (\fBbundle install\fR \fIbundle\-install\.1\.html\fR, \fBBundler\.setup\fR, \fBBundler\.require\fR) behave exactly the same as if any groups not matching the current platform were explicitly excluded\.
.
+.SS "FORCE_RUBY_PLATFORM"
+If you always want the pure ruby variant of a gem to be chosen over platform specific variants, you can use the \fBforce_ruby_platform\fR option:
+.
+.IP "" 4
+.
+.nf
+
+gem "ffi", force_ruby_platform: true
+.
+.fi
+.
+.IP "" 0
+.
+.P
+This can be handy (assuming the pure ruby variant works fine) when:
+.
+.IP "\(bu" 4
+You\'re having issues with the platform specific variant\.
+.
+.IP "\(bu" 4
+The platform specific variant does not yet support a newer ruby (and thus has a \fBrequired_ruby_version\fR upper bound), but you still want your Gemfile{\.lock} files to resolve under that ruby\.
+.
+.IP "" 0
+.
.SS "SOURCE"
You can select an alternate Rubygems repository for a gem using the \':source\' option\.
.
@@ -688,7 +712,7 @@ The \fB\.gemspec\fR \fIhttp://guides\.rubygems\.org/specification\-reference/\fR
If you wish to use Bundler to help install dependencies for a gem while it is being developed, use the \fBgemspec\fR method to pull in the dependencies listed in the \fB\.gemspec\fR file\.
.
.P
-The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fB:path => \'\.\'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
+The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fBpath: \'\.\'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
.
.P
The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, the glob it uses to look for the gemspec (defaults to: "{,\fI,\fR/*}\.gemspec"), what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
diff --git a/lib/bundler/man/gemfile.5.ronn b/lib/bundler/man/gemfile.5.ronn
index f94a174b72..e23e1d49df 100644
--- a/lib/bundler/man/gemfile.5.ronn
+++ b/lib/bundler/man/gemfile.5.ronn
@@ -231,6 +231,20 @@ All operations involving groups ([`bundle install`](bundle-install.1.html), `Bun
`Bundler.require`) behave exactly the same as if any groups not
matching the current platform were explicitly excluded.
+### FORCE_RUBY_PLATFORM
+
+If you always want the pure ruby variant of a gem to be chosen over platform
+specific variants, you can use the `force_ruby_platform` option:
+
+ gem "ffi", force_ruby_platform: true
+
+This can be handy (assuming the pure ruby variant works fine) when:
+
+* You're having issues with the platform specific variant.
+* The platform specific variant does not yet support a newer ruby (and thus has
+ a `required_ruby_version` upper bound), but you still want your Gemfile{.lock}
+ files to resolve under that ruby.
+
### SOURCE
You can select an alternate Rubygems repository for a gem using the ':source'
@@ -495,8 +509,8 @@ the `.gemspec` file.
The `gemspec` method adds any runtime dependencies as gem requirements in the
default group. It also adds development dependencies as gem requirements in the
-`development` group. Finally, it adds a gem requirement on your project (`:path
-=> '.'`). In conjunction with `Bundler.setup`, this allows you to require project
+`development` group. Finally, it adds a gem requirement on your project (`path:
+'.'`). In conjunction with `Bundler.setup`, this allows you to require project
files in your test code as you would if the project were installed as a gem; you
need not manipulate the load path manually or require project files via relative
paths.
diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb
index 69074925a6..7f7e8227f9 100644
--- a/lib/bundler/match_platform.rb
+++ b/lib/bundler/match_platform.rb
@@ -15,7 +15,6 @@ module Bundler
return true if Gem::Platform::RUBY == gemspec_platform
return true if local_platform == gemspec_platform
gemspec_platform = Gem::Platform.new(gemspec_platform)
- return true if GemHelpers.generic(gemspec_platform) === local_platform
return true if gemspec_platform === local_platform
false
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 18eb18160d..972a4c254d 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -143,9 +143,12 @@ module Bundler
end
spec_group_ruby = SpecGroup.create_for(specs_by_platform, [Gem::Platform::RUBY], Gem::Platform::RUBY)
- groups << spec_group_ruby if spec_group_ruby
+ if spec_group_ruby
+ spec_group_ruby.force_ruby_platform = dependency.force_ruby_platform
+ groups << spec_group_ruby
+ end
- next groups if @resolving_only_for_ruby
+ next groups if @resolving_only_for_ruby || dependency.force_ruby_platform
spec_group = SpecGroup.create_for(specs_by_platform, @platforms, platform)
groups << spec_group
@@ -284,7 +287,7 @@ module Bundler
if specs_matching_requirement.any?
specs = specs_matching_requirement
matching_part = requirement_label
- requirement_label = "#{requirement_label} #{requirement.__platform}"
+ requirement_label = "#{requirement_label}' with platform '#{requirement.__platform}"
end
message = String.new("Could not find gem '#{requirement_label}'#{extra_message} in #{source}#{cache_message}.\n")
diff --git a/lib/bundler/resolver/spec_group.rb b/lib/bundler/resolver/spec_group.rb
index 18ab5a52a3..4de5b91aa6 100644
--- a/lib/bundler/resolver/spec_group.rb
+++ b/lib/bundler/resolver/spec_group.rb
@@ -4,7 +4,7 @@ module Bundler
class Resolver
class SpecGroup
attr_accessor :name, :version, :source
- attr_accessor :activated_platforms
+ attr_accessor :activated_platforms, :force_ruby_platform
def self.create_for(specs, all_platforms, specific_platform)
specific_platform_specs = specs[specific_platform]
@@ -35,6 +35,7 @@ module Bundler
specs.map do |s|
lazy_spec = LazySpecification.new(name, version, s.platform, source)
+ lazy_spec.force_ruby_platform = force_ruby_platform
lazy_spec.dependencies.replace s.dependencies
lazy_spec
end
@@ -88,7 +89,7 @@ module Bundler
dependencies = []
@specs[platform].first.dependencies.each do |dep|
next if dep.type == :development
- dependencies << DepProxy.get_proxy(dep, platform)
+ dependencies << DepProxy.get_proxy(Dependency.new(dep.name, dep.requirement), platform)
end
dependencies
end
@@ -98,10 +99,10 @@ module Bundler
return [] if spec.is_a?(LazySpecification)
dependencies = []
unless spec.required_ruby_version.none?
- dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform)
+ dependencies << DepProxy.get_proxy(Dependency.new("Ruby\0", spec.required_ruby_version), platform)
end
unless spec.required_rubygems_version.none?
- dependencies << DepProxy.get_proxy(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
+ dependencies << DepProxy.get_proxy(Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
end
dependencies
end
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index af669d7d0b..d679d20c21 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -216,32 +216,15 @@ module Gem
require "rubygems/platform"
class Platform
- JAVA = Gem::Platform.new("java") unless defined?(JAVA)
- MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
- MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64)
- MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW)
- X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW)
- end
-
- Platform.singleton_class.module_eval do
- unless Platform.singleton_methods.include?(:match_spec?)
- def match_spec?(spec)
- match_gem?(spec.platform, spec.name)
- end
-
- def match_gem?(platform, gem_name)
- match_platforms?(platform, Gem.platforms)
- end
-
- private
-
- def match_platforms?(platform, platforms)
- platforms.any? do |local_platform|
- platform.nil? ||
- local_platform == platform ||
- (local_platform != Gem::Platform::RUBY && local_platform =~ platform)
- end
- end
+ JAVA = Gem::Platform.new("java")
+ MSWIN = Gem::Platform.new("mswin32")
+ MSWIN64 = Gem::Platform.new("mswin64")
+ MINGW = Gem::Platform.new("x86-mingw32")
+ X64_MINGW = [Gem::Platform.new("x64-mingw32"),
+ Gem::Platform.new("x64-mingw-ucrt")].freeze
+
+ if RUBY_ENGINE == "truffleruby" && !defined?(REUSE_AS_BINARY_ON_TRUFFLERUBY)
+ REUSE_AS_BINARY_ON_TRUFFLERUBY = %w[libv8 sorbet-static].freeze
end
end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 85a9d1537b..06257ac93f 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -24,13 +24,13 @@ module Bundler
# use a hash here to ensure constant lookup time in the `any?` call above
handled[dep.name] << dep
- specs_for_dep = spec_for_dependency(dep, match_current_platform)
+ specs_for_dep = specs_for_dependency(dep, match_current_platform)
if specs_for_dep.any?
specs.concat(specs_for_dep)
specs_for_dep.first.dependencies.each do |d|
next if d.type == :development
- d = DepProxy.get_proxy(d, dep.__platform) unless match_current_platform
+ d = DepProxy.get_proxy(Dependency.new(d.name, d.requirement), dep.__platform) unless match_current_platform
deps << d
end
elsif check
@@ -173,12 +173,13 @@ module Bundler
@specs.sort_by(&:name).each {|s| yield s }
end
- def spec_for_dependency(dep, match_current_platform)
- specs_for_platforms = lookup[dep.name]
+ def specs_for_dependency(dep, match_current_platform)
+ specs_for_name = lookup[dep.name]
if match_current_platform
- GemHelpers.select_best_platform_match(specs_for_platforms.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
+ GemHelpers.select_best_platform_match(specs_for_name, Bundler.local_platform)
else
- GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
+ specs_for_name_and_platform = GemHelpers.select_best_platform_match(specs_for_name, dep.force_ruby_platform ? Gem::Platform::RUBY : dep.__platform)
+ specs_for_name_and_platform.any? ? specs_for_name_and_platform : specs_for_name
end
end
diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb
index 89b23b26aa..b3f925773b 100644
--- a/lib/rubygems/gem_runner.rb
+++ b/lib/rubygems/gem_runner.rb
@@ -10,11 +10,6 @@ require_relative 'command_manager'
require_relative 'deprecate'
##
-# Load additional plugins from $LOAD_PATH
-
-Gem.load_env_plugins rescue nil
-
-##
# Run an instance of the gem program.
#
# Gem::GemRunner is only intended for internal use by RubyGems itself. It
@@ -37,6 +32,9 @@ class Gem::GemRunner
do_configuration args
+ Gem.load_env_plugins rescue nil
+ Gem.load_plugins
+
cmd = @command_manager_class.instance
cmd.command_names.each do |command_name|
@@ -75,5 +73,3 @@ class Gem::GemRunner
Gem::Command.extra_args = Gem.configuration[:gem]
end
end
-
-Gem.load_plugins
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 0613399890..7484145467 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -340,7 +340,7 @@ class Gem::Installer
say spec.post_install_message if options[:post_install_message] && !spec.post_install_message.nil?
- Gem::Specification.reset
+ Gem::Specification.add_spec(spec)
run_post_install_hooks
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index f48f4bdc76..8fcabf164d 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -159,6 +159,10 @@ class Gem::Platform
def ===(other)
return nil unless Gem::Platform === other
+ # universal-mingw32 matches x64-mingw-ucrt
+ return true if (@cpu == 'universal' or other.cpu == 'universal') and
+ @os.start_with?('mingw') and other.os.start_with?('mingw')
+
# cpu
([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or
(@cpu == 'arm' and other.cpu.start_with?("arm"))) and
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 56db0945eb..f6704cbc17 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -883,6 +883,21 @@ class Gem::Specification < Gem::BasicSpecification
end
##
+ # Adds +spec+ to the known specifications, keeping the collection
+ # properly sorted.
+
+ def self.add_spec(spec)
+ return if _all.include? spec
+
+ _all << spec
+ stubs << spec
+ (@@stubs_by_name[spec.name] ||= []) << spec
+
+ _resort!(@@stubs_by_name[spec.name])
+ _resort!(stubs)
+ end
+
+ ##
# Returns all specifications. This method is discouraged from use.
# You probably want to use one of the Enumerable methods instead.