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

ruby-changes:73424

From: Hiroshi <ko1@a...>
Date: Mon, 5 Sep 2022 14:37:27 +0900 (JST)
Subject: [ruby-changes:73424] 3eca1e438d (master): Merge https://github.com/rubygems/rubygems/commit/16c3535413afebcdbab7582c6017c27b5da8a8dc

https://git.ruby-lang.org/ruby.git/commit/?id=3eca1e438d

From 3eca1e438db6fabaa7cd5e5a7120da147ac0ec26 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Mon, 5 Sep 2022 09:15:30 +0900
Subject: Merge
 https://github.com/rubygems/rubygems/commit/16c3535413afebcdbab7582c6017c27b5da8a8dc

---
 lib/bundler.rb                                     |  61 +-----
 lib/bundler/cli/install.rb                         |   5 +-
 lib/bundler/definition.rb                          |   6 +-
 lib/bundler/errors.rb                              |   1 -
 lib/bundler/feature_flag.rb                        |   1 -
 lib/bundler/gem_version_promoter.rb                |  22 +--
 lib/bundler/man/bundle-add.1                       |   2 +-
 lib/bundler/man/bundle-binstubs.1                  |   2 +-
 lib/bundler/man/bundle-cache.1                     |   2 +-
 lib/bundler/man/bundle-check.1                     |   2 +-
 lib/bundler/man/bundle-clean.1                     |   2 +-
 lib/bundler/man/bundle-config.1                    |  13 +-
 lib/bundler/man/bundle-config.1.ronn               |   5 +-
 lib/bundler/man/bundle-doctor.1                    |   2 +-
 lib/bundler/man/bundle-exec.1                      |   2 +-
 lib/bundler/man/bundle-gem.1                       |   2 +-
 lib/bundler/man/bundle-help.1                      |  13 ++
 lib/bundler/man/bundle-help.1.ronn                 |  12 ++
 lib/bundler/man/bundle-info.1                      |   2 +-
 lib/bundler/man/bundle-init.1                      |   2 +-
 lib/bundler/man/bundle-inject.1                    |   2 +-
 lib/bundler/man/bundle-install.1                   |  31 +---
 lib/bundler/man/bundle-install.1.ronn              |  29 ---
 lib/bundler/man/bundle-list.1                      |   2 +-
 lib/bundler/man/bundle-lock.1                      |   2 +-
 lib/bundler/man/bundle-open.1                      |   2 +-
 lib/bundler/man/bundle-outdated.1                  |   2 +-
 lib/bundler/man/bundle-platform.1                  |   2 +-
 lib/bundler/man/bundle-plugin.1                    |  81 ++++++++
 lib/bundler/man/bundle-plugin.1.ronn               |  59 ++++++
 lib/bundler/man/bundle-pristine.1                  |   2 +-
 lib/bundler/man/bundle-remove.1                    |   2 +-
 lib/bundler/man/bundle-show.1                      |   2 +-
 lib/bundler/man/bundle-update.1                    |   2 +-
 lib/bundler/man/bundle-viz.1                       |   2 +-
 lib/bundler/man/bundle.1                           |   8 +-
 lib/bundler/man/bundle.1.ronn                      |   5 +-
 lib/bundler/man/gemfile.5                          |   2 +-
 lib/bundler/man/index.txt                          |   2 +
 lib/bundler/match_remote_metadata.rb               |   5 +-
 lib/bundler/plugin.rb                              |   2 +
 lib/bundler/plugin/installer/rubygems.rb           |   4 -
 lib/bundler/resolver.rb                            | 149 +++++++--------
 lib/bundler/resolver/base.rb                       |  50 +++++
 lib/bundler/rubygems_integration.rb                |   4 -
 lib/bundler/settings.rb                            |   7 -
 lib/bundler/source/git.rb                          |  10 +-
 lib/bundler/source/path/installer.rb               |  23 +--
 lib/bundler/source/rubygems.rb                     |  62 +------
 lib/bundler/spec_set.rb                            |  10 +
 spec/bundler/bundler/bundler_spec.rb               | 128 -------------
 .../bundler/bundler/endpoint_specification_spec.rb |  27 +++
 spec/bundler/bundler/gem_version_promoter_spec.rb  |   9 -
 spec/bundler/install/binstubs_spec.rb              |   4 +-
 spec/bundler/install/gemfile/sources_spec.rb       |  53 ++++++
 spec/bundler/install/gems/compact_index_spec.rb    |  12 --
 spec/bundler/install/gems/dependency_api_spec.rb   |  12 --
 spec/bundler/install/gems/flex_spec.rb             |  75 +++-----
 spec/bundler/install/gems/sudo_spec.rb             | 205 ---------------------
 spec/bundler/plugins/install_spec.rb               |  23 ++-
 spec/bundler/plugins/source/example_spec.rb        |   8 +-
 spec/bundler/quality_spec.rb                       |   1 -
 spec/bundler/spec_helper.rb                        |   6 -
 spec/bundler/support/filters.rb                    |   3 -
 spec/bundler/support/helpers.rb                    |   9 +-
 spec/bundler/support/sudo.rb                       |  22 ---
 test/rubygems/helper.rb                            |   7 -
 tool/bundler/rubocop_gems.rb.lock                  |   1 +
 tool/bundler/standard_gems.rb.lock                 |   1 +
 69 files changed, 499 insertions(+), 831 deletions(-)
 create mode 100644 lib/bundler/man/bundle-help.1
 create mode 100644 lib/bundler/man/bundle-help.1.ronn
 create mode 100644 lib/bundler/man/bundle-plugin.1
 create mode 100644 lib/bundler/man/bundle-plugin.1.ronn
 create mode 100644 lib/bundler/resolver/base.rb
 delete mode 100644 spec/bundler/install/gems/sudo_spec.rb
 delete mode 100644 spec/bundler/support/sudo.rb

diff --git a/lib/bundler.rb b/lib/bundler.rb
index 24785ef5eb..dc88bbdcb9 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -488,41 +488,9 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L488
       configured_bundle_path.use_system_gems?
     end
 
-    def requires_sudo?
-      return @requires_sudo if defined?(@requires_sudo_ran)
-
-      sudo_present = which "sudo" if settings.allow_sudo?
-
-      if sudo_present
-        # the bundle path and subdirectories need to be writable for RubyGems
-        # to be able to unpack and install gems without exploding
-        path = bundle_path
-        path = path.parent until path.exist?
-
-        # bins are written to a different location on OS X
-        bin_dir = Pathname.new(Bundler.system_bindir)
-        bin_dir = bin_dir.parent until bin_dir.exist?
-
-        # if any directory is not writable, we need sudo
-        files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s]
-        unwritable_files = files.reject {|f| File.writable?(f) }
-        sudo_needed = !unwritable_files.empty?
-        if sudo_needed
-          Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n  #{unwritable_files.map(&:to_s).sort.join("\n  ")}"
-        end
-      end
-
-      @requires_sudo_ran = true
-      @requires_sudo = settings.allow_sudo? && sudo_present && sudo_needed
-    end
-
     def mkdir_p(path, options = {})
-      if requires_sudo? && !options[:no_sudo]
-        sudo "mkdir -p '#{path}'" unless File.exist?(path)
-      else
-        SharedHelpers.filesystem_access(path, :write) do |p|
-          FileUtils.mkdir_p(p)
-        end
+      SharedHelpers.filesystem_access(path, :write) do |p|
+        FileUtils.mkdir_p(p)
       end
     end
 
@@ -539,31 +507,6 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L507
       end
     end
 
-    def sudo(str)
-      SUDO_MUTEX.synchronize do
-        prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, "").strip + " "
-        Your user account isn't allowed to install to the system RubyGems.
-        You can cancel this installation and run:
-
-            bundle config set --local path 'vendor/bundle'
-            bundle install
-
-        to install the gems into ./vendor/bundle/, or you can enter your password
-        and install the bundled gems to RubyGems using sudo.
-
-        Password:
-        PROMPT
-
-        unless @prompted_for_sudo ||= system(%(sudo -k -p "#{prompt}" true))
-          raise SudoNotPermittedError,
-            "Bundler requires sudo access to install at the moment. " \
-            "Try installing again, granting Bundler sudo access when prompted, or installing into a different path."
-        end
-
-        `sudo -p "#{prompt}" #{str}`
-      end
-    end
-
     def read_file(file)
       SharedHelpers.filesystem_access(file, :read) do
         File.open(file, "r:UTF-8", &:read)
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 851ae9b840..1765621cb3 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -94,9 +94,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/install.rb#L94
 
     def warn_if_root
       return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero?
-      Bundler.ui.warn "Don't run Bundler as root. Bundler can ask for sudo " \
-        "if it is needed, and installing your bundle as root will break this " \
-        "application for all non-root users on this machine.", :wrap => true
+      Bundler.ui.warn "Don't run Bundler as root. Installing your bundle as root " \
+                      "will break this application for all non-root users on this machine.", :wrap => true
     end
 
     def dependencies_count_for(definition)
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 8bd9e11f32..79369ec374 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -485,7 +485,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L485
       @resolver ||= begin
         last_resolve = converge_locked_specs
         remove_ruby_from_platforms_if_necessary!(dependencies)
-        Resolver.new(source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
+        Resolver.new(source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve(last_resolve), platforms)
       end
     end
 
@@ -878,9 +878,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L878
       end
     end
 
-    def additional_base_requirements_for_resolve
+    def additional_base_requirements_for_resolve(last_resolve)
       return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
-      converge_specs(@originally_locked_specs).map do |locked_spec|
+      converge_specs(@originally_locked_specs - last_resolve).map do |locked_spec|
          (... truncated)

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

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