ruby-changes:66708
From: Hiroshi <ko1@a...>
Date: Wed, 7 Jul 2021 15:32:10 +0900 (JST)
Subject: [ruby-changes:66708] c082c6eb7c (master): Sync RubyGems and Bundler with upstream
https://git.ruby-lang.org/ruby.git/commit/?id=c082c6eb7c From c082c6eb7c786a432bea23cf78839f64585cb630 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Wed, 7 Jul 2021 14:07:29 +0900 Subject: Sync RubyGems and Bundler with upstream --- lib/bundler.rb | 2 +- lib/bundler/cli/doctor.rb | 12 +- lib/bundler/cli/install.rb | 2 +- lib/bundler/compact_index_client.rb | 4 +- lib/bundler/current_ruby.rb | 8 +- lib/bundler/definition.rb | 44 ++----- lib/bundler/dsl.rb | 14 +-- lib/bundler/installer.rb | 8 +- lib/bundler/lockfile_parser.rb | 22 +--- lib/bundler/plugin/installer.rb | 2 +- lib/bundler/rubygems_ext.rb | 2 + lib/bundler/source/rubygems.rb | 13 -- lib/bundler/source_list.rb | 55 ++++++--- .../lib/connection_pool/monotonic_time.rb | 2 +- .../lib/connection_pool/timed_stack.rb | 4 +- lib/bundler/worker.rb | 4 +- lib/rubygems.rb | 2 +- lib/rubygems/core_ext/tcpsocket_init.rb | 4 +- lib/rubygems/deprecate.rb | 59 ++++++++- lib/rubygems/gemcutter_utilities.rb | 13 +- lib/rubygems/installer.rb | 2 +- lib/rubygems/remote_fetcher.rb | 15 +-- lib/rubygems/request/connection_pools.rb | 2 +- lib/rubygems/request/http_pool.rb | 2 +- lib/rubygems/request_set.rb | 2 +- lib/rubygems/specification.rb | 2 +- lib/rubygems/uri_parser.rb | 8 ++ lib/rubygems/uri_parsing.rb | 23 ---- lib/rubygems/user_interaction.rb | 2 +- spec/bundler/bundler/cli_spec.rb | 34 +++--- spec/bundler/bundler/definition_spec.rb | 2 +- spec/bundler/bundler/source_list_spec.rb | 42 +++---- spec/bundler/commands/doctor_spec.rb | 24 +++- spec/bundler/commands/update_spec.rb | 88 ++++++++++++++ spec/bundler/install/gemfile/eval_gemfile_spec.rb | 32 +++++ spec/bundler/install/gemfile/sources_spec.rb | 70 +++++++++++ spec/bundler/install/gems/compact_index_spec.rb | 4 +- spec/bundler/install/gems/dependency_api_spec.rb | 4 +- spec/bundler/install/global_cache_spec.rb | 7 +- spec/bundler/lock/lockfile_spec.rb | 82 +------------ spec/bundler/realworld/edgecases_spec.rb | 133 +-------------------- spec/bundler/realworld/slow_perf_spec.rb | 10 +- spec/bundler/spec_helper.rb | 2 +- spec/bundler/support/api_request_limit_hax.rb | 16 +++ .../support/artifice/compact_index_rate_limited.rb | 2 +- spec/bundler/support/artifice/endpoint.rb | 2 +- spec/bundler/support/hax.rb | 25 ---- spec/bundler/support/helpers.rb | 4 - spec/bundler/support/matchers.rb | 8 +- spec/bundler/support/path.rb | 4 + test/rubygems/helper.rb | 2 +- test/rubygems/test_gem_gemcutter_utilities.rb | 12 ++ 52 files changed, 477 insertions(+), 466 deletions(-) delete mode 100644 lib/rubygems/uri_parsing.rb create mode 100644 spec/bundler/support/api_request_limit_hax.rb diff --git a/lib/bundler.rb b/lib/bundler.rb index 8b9e870..a7d5d1e 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -37,7 +37,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L37 environment_preserver = EnvironmentPreserver.from_env ORIGINAL_ENV = environment_preserver.restore environment_preserver.replace_with_backup - SUDO_MUTEX = Mutex.new + SUDO_MUTEX = Thread::Mutex.new autoload :Definition, File.expand_path("bundler/definition", __dir__) autoload :Dependency, File.expand_path("bundler/dependency", __dir__) diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb index 2986ddbc..959b1b5 100644 --- a/lib/bundler/cli/doctor.rb +++ b/lib/bundler/cli/doctor.rb @@ -100,8 +100,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/doctor.rb#L100 files_not_readable_or_writable = [] files_not_rw_and_owned_by_different_user = [] files_not_owned_by_current_user_but_still_rw = [] + broken_symlinks = [] Find.find(Bundler.bundle_path.to_s).each do |f| - if !File.writable?(f) || !File.readable?(f) + if !File.exist?(f) + broken_symlinks << f + elsif !File.writable?(f) || !File.readable?(f) if File.stat(f).uid != Process.uid files_not_rw_and_owned_by_different_user << f else @@ -113,6 +116,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/doctor.rb#L116 end ok = true + + if broken_symlinks.any? + Bundler.ui.warn "Broken links exist in the Bundler home. Please report them to the offending gem's upstream repo. These files are:\n - #{broken_symlinks.join("\n - ")}" + + ok = false + end + if files_not_owned_by_current_user_but_still_rw.any? Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \ "user, but are still readable/writable. These files are:\n - #{files_not_owned_by_current_user_but_still_rw.join("\n - ")}" diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 47c1da1..5e39e2a 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -104,7 +104,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/install.rb#L104 private def warn_if_root - return if Bundler.settings[:silence_root_warning] || Bundler::WINDOWS || !Process.uid.zero? + 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 diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb index cf67f0e..d5dbeb3 100644 --- a/lib/bundler/compact_index_client.rb +++ b/lib/bundler/compact_index_client.rb @@ -5,7 +5,7 @@ require "set" https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client.rb#L5 module Bundler class CompactIndexClient - DEBUG_MUTEX = Mutex.new + DEBUG_MUTEX = Thread::Mutex.new def self.debug return unless ENV["DEBUG_COMPACT_INDEX"] DEBUG_MUTEX.synchronize { warn("[#{self}] #{yield}") } @@ -25,7 +25,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client.rb#L25 @endpoints = Set.new @info_checksums_by_name = {} @parsed_checksums = false - @mutex = Mutex.new + @mutex = Thread::Mutex.new end def execution_mode=(block) diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb index b8c7cad..f84d68e 100644 --- a/lib/bundler/current_ruby.rb +++ b/lib/bundler/current_ruby.rb @@ -65,19 +65,19 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/current_ruby.rb#L65 end def mswin? - Bundler::WINDOWS + Gem.win_platform? end def mswin64? - Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64" + Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64" end def mingw? - Bundler::WINDOWS && 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 == "mingw32" && Bundler.local_platform.cpu != "x64" end def x64_mingw? - Bundler::WINDOWS && 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 == "mingw32" && 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 0d7630e..8998e3b 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -61,10 +61,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L61 @unlocking_bundler = false @unlocking = unlock else - unlock = unlock.dup @unlocking_bundler = unlock.delete(:bundler) - unlock.delete_if {|_k, v| Array(v).empty? } - @unlocking = !unlock.empty? + @unlocking = unlock.any? {|_k, v| !Array(v).empty? } end @dependencies = dependencies @@ -111,8 +109,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L109 @locked_platforms = [] end - @locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) } - @multisource_allowed = @locked_gem_sources.any?(&:multiple_remotes?) && Bundler.frozen_bundle? + locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) } + @multisource_allowed = locked_gem_sources.size == 1 && locked_gem_sources.first.multiple_remotes? && Bundler.frozen_bundle? if @multisource_allowed unless sources.aggregate_glo (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/