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

ruby-changes:70411

From: Hiroshi <ko1@a...>
Date: Tue, 21 Dec 2021 15:27:29 +0900 (JST)
Subject: [ruby-changes:70411] 69dc2ea465 (master): Merge RubyGems-3.3.0 and Bundler-2.3.0

https://git.ruby-lang.org/ruby.git/commit/?id=69dc2ea465

From 69dc2ea46538f47ff5edda3bb16863034bd19069 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Tue, 21 Dec 2021 14:50:44 +0900
Subject: Merge RubyGems-3.3.0 and Bundler-2.3.0

---
 lib/bundler.rb                                |   8 ++
 lib/bundler/cli.rb                            |   2 +
 lib/bundler/cli/install.rb                    |   2 +
 lib/bundler/definition.rb                     |   2 +-
 lib/bundler/fetcher.rb                        |   3 -
 lib/bundler/installer.rb                      |   2 +-
 lib/bundler/lockfile_parser.rb                |  23 ++--
 lib/bundler/plugin/installer.rb               |   2 +-
 lib/bundler/rubygems_integration.rb           |  33 ++----
 lib/bundler/self_manager.rb                   |  73 +++++++++++++
 lib/bundler/source/metadata.rb                |   2 +-
 lib/bundler/templates/Executable.bundler      |   2 +-
 lib/bundler/version.rb                        |   2 +-
 lib/rubygems.rb                               |   2 +-
 spec/bundler/bundler/plugin/installer_spec.rb |   2 +-
 spec/bundler/commands/binstubs_spec.rb        |  18 +++-
 spec/bundler/commands/check_spec.rb           |   4 +-
 spec/bundler/lock/lockfile_spec.rb            | 145 ++++++--------------------
 spec/bundler/runtime/platform_spec.rb         |   2 +-
 spec/bundler/runtime/self_management_spec.rb  | 109 +++++++++++++++++++
 spec/bundler/support/filters.rb               |   1 +
 spec/bundler/support/hax.rb                   |   2 +-
 spec/bundler/support/helpers.rb               |   5 +-
 tool/bundler/rubocop_gems.rb.lock             |   2 +-
 tool/bundler/standard_gems.rb.lock            |   2 +-
 tool/bundler/test_gems.rb.lock                |   2 +-
 26 files changed, 278 insertions(+), 174 deletions(-)
 create mode 100644 lib/bundler/self_manager.rb
 create mode 100644 spec/bundler/runtime/self_management_spec.rb

diff --git a/lib/bundler.rb b/lib/bundler.rb
index 81dfd05d26d..89865a82544 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -66,6 +66,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L66
   autoload :RubyDsl,                File.expand_path("bundler/ruby_dsl", __dir__)
   autoload :RubyVersion,            File.expand_path("bundler/ruby_version", __dir__)
   autoload :Runtime,                File.expand_path("bundler/runtime", __dir__)
+  autoload :SelfManager,            File.expand_path("bundler/self_manager", __dir__)
   autoload :Settings,               File.expand_path("bundler/settings", __dir__)
   autoload :SharedHelpers,          File.expand_path("bundler/shared_helpers", __dir__)
   autoload :Source,                 File.expand_path("bundler/source", __dir__)
@@ -643,6 +644,13 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L644
       Bundler.rubygems.clear_paths
     end
 
+    def self_manager
+      @self_manager ||= begin
+                          require_relative "bundler/self_manager"
+                          Bundler::SelfManager.new
+                        end
+    end
+
     private
 
     def eval_yaml_gemspec(path, contents)
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 36d0472c624..f6e20e7c675 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -61,6 +61,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L61
         Bundler.reset_settings_and_root!
       end
 
+      Bundler.self_manager.restart_with_locked_bundler_if_needed
+
       Bundler.settings.set_command_option_if_given :retry, options[:retry]
 
       current_cmd = args.last[:current_command].name
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 4c1915fea6e..85f702bc645 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -12,6 +12,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/install.rb#L12
 
       warn_if_root
 
+      Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
+
       Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
 
       # Disable color in deployment mode
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 84f0367ac70..9a94bd3ed3a 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -294,7 +294,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L294
 
         if updating_major = locked_major < current_major
           Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \
-                          "after which you will be unable to return to Bundler #{@locked_bundler_version.segments.first}."
+                          "after which you will be unable to return to Bundler #{locked_major}."
         end
       end
 
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 6dd6d089eb0..a453157e686 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -122,7 +122,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/fetcher.rb#L122
 
     # return the specs in the bundler format as an index
     def specs(gem_names, source)
-      old = Bundler.rubygems.sources
       index = Bundler::Index.new
 
       if Bundler::Fetcher.disable_endpoint
@@ -153,8 +152,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/fetcher.rb#L152
     rescue CertificateFailureError
       Bundler.ui.info "" if gem_names && use_api # newline after dots
       raise
-    ensure
-      Bundler.rubygems.sources = old
     end
 
     def use_api
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 49ff177c0ff..61bf1e06d4b 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -239,7 +239,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/installer.rb#L239
 
     def ensure_specs_are_compatible!
       system_ruby = Bundler::RubyVersion.system
-      rubygems_version = Gem::Version.create(Gem::VERSION)
+      rubygems_version = Bundler.rubygems.version
       @definition.specs.each do |spec|
         if required_ruby_version = spec.required_ruby_version
           unless required_ruby_version.satisfied_by?(system_ruby.gem_version)
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 6ff4910a36a..e074cbfc33a 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -46,6 +46,16 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lockfile_parser.rb#L46
       attributes
     end
 
+    def self.bundled_with
+      lockfile = Bundler.default_lockfile
+      return unless lockfile.file?
+
+      lockfile_contents = Bundler.read_file(lockfile)
+      return unless lockfile_contents.include?(BUNDLED)
+
+      lockfile_contents.split(BUNDLED).last.strip
+    end
+
     def initialize(lockfile)
       @platforms    = []
       @sources      = []
@@ -77,25 +87,12 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lockfile_parser.rb#L87
         end
       end
       @specs = @specs.values.sort_by(&:identifier)
-      warn_for_outdated_bundler_version
     rescue ArgumentError => e
       Bundler.ui.debug(e)
       raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
         "and then `bundle install` to generate a new lockfile."
     end
 
-    def warn_for_outdated_bundler_version
-      return unless bundler_version
-      return if bundler_version.segments.last == "dev"
-      prerelease_text = bundler_version.prerelease? ? " --pre" : ""
-      current_version = Gem::Version.create(Bundler::VERSION)
-      return unless current_version < bundler_version
-      Bundler.ui.warn "Warning: the running version of Bundler (#{current_version}) is older " \
-           "than the version that created the lockfile (#{bundler_version}). We suggest you to " \
-           "upgrade to the version that created the lockfile by running `gem install " \
-           "bundler:#{bundler_version}#{prerelease_text}`.\n"
-    end
-
     private
 
     TYPES = {
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index d7411fff450..81ecafa470b 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -21,7 +21,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/plugin/installer.rb#L21
         elsif options[:local_git]
           install_local_git(names, version, options)
         else
-          sources = options[:source] || Bundler.rubygems.sources
+          sources = options[:source] || Gem.sources
           install_rubygems(names, version, sources)
         end
       end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index effb88c1cd0..785f7fa360a 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -12,25 +12,21 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_integration.rb#L12
       EXT_LOCK = Monitor.new
     end
 
-    def self.version
-      @version ||= Gem::Version.new(Gem::VERSION)
-    end
-
-    def self.provides?(req_str)
-      Gem::Requirement.new(req_str).satisfied_by?(version)
-    end
-
     def initialize
       @replaced_methods = {}
       backport_ext_builder_monitor
     end
 
     def version
-      self.class.version
+      @version ||= Gem.rubygems_version
     end
 
     def provides?(req_str)
-      self.class.provides?(req_str)
+      Gem::Requirement.new(req_str).satisfied_by?(version)
+    end
+
+    def supports_bundler_trampolining?
+      provides?(">= 3.3.0.a")
     end
 
     def build_args
@@ -142,19 +138,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_integration.rb#L138
       end
     end
 
-    def sources=(val)
-      # Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
-      # If that file exists, its settings (incl (... truncated)

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

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