[前][次][番号順一覧][スレッド一覧]

ruby-changes:70239

From: Hiroshi <ko1@a...>
Date: Wed, 15 Dec 2021 18:05:38 +0900 (JST)
Subject: [ruby-changes:70239] 7e084ed707 (master): Merge RubyGems and Bundler master

https://git.ruby-lang.org/ruby.git/commit/?id=7e084ed707

From 7e084ed707310139b351f6d30af435676422af62 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Tue, 14 Dec 2021 21:14:58 +0900
Subject: Merge RubyGems and Bundler master

  Merge from https://github.com/rubygems/rubygems/commit/793ad95ecb40e84a1dcb4cb60f2686843ed90de5
---
 .../connection_pool/lib/connection_pool/wrapper.rb |  4 +-
 lib/rubygems.rb                                    | 43 ++++++++++++----------
 lib/rubygems/commands/setup_command.rb             |  4 +-
 lib/rubygems/requirement.rb                        |  2 +-
 lib/rubygems/specification.rb                      | 20 +++++-----
 lib/rubygems/version.rb                            |  7 ----
 spec/bundler/commands/clean_spec.rb                |  2 +-
 spec/bundler/commands/exec_spec.rb                 | 12 +++---
 spec/bundler/install/gems/standalone_spec.rb       |  2 +-
 test/rubygems/test_gem_specification.rb            |  6 +--
 test/rubygems/test_project_sanity.rb               | 12 ------
 test/rubygems/test_rubygems.rb                     | 23 ++++++++++++
 tool/bundler/rubocop_gems.rb.lock                  |  1 +
 tool/bundler/standard_gems.rb.lock                 |  1 +
 14 files changed, 73 insertions(+), 66 deletions(-)

diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb
index 9d94c2c0f09..880170c06b0 100644
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb
+++ b/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb
@@ -32,13 +32,13 @@ class Bundler::ConnectionPool https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb#L32
 
     # rubocop:disable Style/MethodMissingSuper
     # rubocop:disable Style/MissingRespondToMissing
-    if ::Gem.ruby_version >= ::Gem::Version.new("3.0.0")
+    if ::RUBY_VERSION >= "3.0.0"
       def method_missing(name, *args, **kwargs, &block)
         with do |connection|
           connection.send(name, *args, **kwargs, &block)
         end
       end
-    elsif ::Gem.ruby_version >= ::Gem::Version.new("2.7.0")
+    elsif ::RUBY_VERSION >= "2.7.0"
       ruby2_keywords def method_missing(name, *args, &block)
         with do |connection|
           connection.send(name, *args, &block)
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index f803e47628e..b7dda38d522 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1293,7 +1293,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L1293
     end
 
     def default_gem_load_paths
-      @default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1]
+      @default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1].map do |lp|
+        expanded = File.expand_path(lp)
+        next expanded unless File.exist?(expanded)
+
+        File.realpath(expanded)
+      end
     end
   end
 
@@ -1310,37 +1315,19 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L1315
   autoload :Licenses,           File.expand_path('rubygems/util/licenses', __dir__)
   autoload :NameTuple,          File.expand_path('rubygems/name_tuple', __dir__)
   autoload :PathSupport,        File.expand_path('rubygems/path_support', __dir__)
-  autoload :Platform,           File.expand_path('rubygems/platform', __dir__)
   autoload :RequestSet,         File.expand_path('rubygems/request_set', __dir__)
-  autoload :Requirement,        File.expand_path('rubygems/requirement', __dir__)
   autoload :Resolver,           File.expand_path('rubygems/resolver', __dir__)
   autoload :Source,             File.expand_path('rubygems/source', __dir__)
   autoload :SourceList,         File.expand_path('rubygems/source_list', __dir__)
   autoload :SpecFetcher,        File.expand_path('rubygems/spec_fetcher', __dir__)
-  autoload :Specification,      File.expand_path('rubygems/specification', __dir__)
   autoload :Util,               File.expand_path('rubygems/util', __dir__)
   autoload :Version,            File.expand_path('rubygems/version', __dir__)
 end
 
 require_relative 'rubygems/exceptions'
+require_relative 'rubygems/specification'
 
 # REFACTOR: This should be pulled out into some kind of hacks file.
-begin
-  ##
-  # Defaults the Ruby implementation wants to provide for RubyGems
-
-  require "rubygems/defaults/#{RUBY_ENGINE}"
-rescue LoadError
-end
-
-##
-# Loads the default specs.
-Gem::Specification.load_defaults
-
-require_relative 'rubygems/core_ext/kernel_gem'
-require_relative 'rubygems/core_ext/kernel_require'
-require_relative 'rubygems/core_ext/kernel_warn'
-
 begin
   ##
   # Defaults the operating system (or packager) wants to provide for RubyGems.
@@ -1356,3 +1343,19 @@ rescue StandardError => e https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L1343
     "the problem and ask for help."
   raise e.class, msg
 end
+
+begin
+  ##
+  # Defaults the Ruby implementation wants to provide for RubyGems
+
+  require "rubygems/defaults/#{RUBY_ENGINE}"
+rescue LoadError
+end
+
+##
+# Loads the default specs.
+Gem::Specification.load_defaults
+
+require_relative 'rubygems/core_ext/kernel_gem'
+require_relative 'rubygems/core_ext/kernel_require'
+require_relative 'rubygems/core_ext/kernel_warn'
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index ed1fcaa4b89..0601dccb075 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -12,8 +12,6 @@ class Gem::Commands::SetupCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L12
   ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
 
   def initialize
-    require 'tmpdir'
-
     super 'setup', 'Install RubyGems',
           :format_executable => false, :document => %w[ri],
           :force => true,
@@ -253,6 +251,8 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L251
       Dir.chdir path do
         bin_file = "gem"
 
+        require 'tmpdir'
+
         dest_file = target_bin_path(bin_dir, bin_file)
         bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
 
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index d2e28fab5b4..9edd6aa7d3c 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/requirement.rb#L1
 # frozen_string_literal: true
-require_relative "deprecate"
+require_relative "version"
 
 ##
 # A Requirement is a set of one or more version restrictions. It supports a
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 40a5bddff6a..dc5e5ba0138 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -9,6 +9,8 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L9
 require_relative 'deprecate'
 require_relative 'basic_specification'
 require_relative 'stub_specification'
+require_relative 'platform'
+require_relative 'requirement'
 require_relative 'specification_policy'
 require_relative 'util/list'
 
@@ -179,18 +181,14 @@ class Gem::Specification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L181
   end
 
   def self.clear_specs # :nodoc:
-    @@all_specs_mutex.synchronize do
-      @@all = nil
-      @@stubs = nil
-      @@stubs_by_name = {}
-      @@spec_with_requirable_file = {}
-      @@active_stub_with_requirable_file = {}
-    end
+    @@all = nil
+    @@stubs = nil
+    @@stubs_by_name = {}
+    @@spec_with_requirable_file = {}
+    @@active_stub_with_requirable_file = {}
   end
   private_class_method :clear_specs
 
-  @@all_specs_mutex = Thread::Mutex.new
-
   clear_specs
 
   # Sentinel object to represent "not found" stubs
@@ -758,7 +756,7 @@ class Gem::Specification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L756
   attr_accessor :specification_version
 
   def self._all # :nodoc:
-    @@all_specs_mutex.synchronize { @@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec) }
+    @@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec)
   end
 
   def self.clear_load_cache # :nodoc:
@@ -1086,7 +1084,7 @@ class Gem::Specification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1084
   # +prerelease+ is true.
 
   def self.latest_specs(prerelease = false)
-    _latest_specs Gem::Specification._all, prerelease
+    _latest_specs Gem::Specification.stubs, prerelease
   end
 
   ##
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 37fd71edc06..42e0f235053 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -149,13 +149,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L149
 # For the last example, single-digit versions are automatically extended with
 # a zero to give a sensible result.
 
-# Our code style opens classes directly without opening the intermediate
-# modules. This works because tha main entrypoint `rubygems.rb`, which defines
-# the root `Gem` module, is usually required first. But in this case we want to
-# allow using `Gem::Version` without loading the rest of rubygems, so we
-# explicit define the `Gem` placeholder module first.
-module Gem; end
-
 require_relative "deprecate"
 
 class Gem::Version
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
index ffaf22dbb32..65231b35fac 100644
--- a/spec/bundler/commands/clean_spec.rb
+++ b/spec/bundler/commands/clean_spec.rb
@@ -638,7 +638,7 @@ RSpec.describe "bundle clean" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/clean_spec.rb#L638
       s.executables = "irb"
     end
 
-    realworld_system_gems "fiddle --version 1.0.6", "tsort --version 0.1.0", "pathname --version  (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]