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

ruby-changes:69741

From: Akinori <ko1@a...>
Date: Tue, 16 Nov 2021 19:42:48 +0900 (JST)
Subject: [ruby-changes:69741] 625cffc808 (master): [ruby/digest] Abort loading if being loaded by gem/bundle pre Ruby 3.0.3

https://git.ruby-lang.org/ruby.git/commit/?id=625cffc808

From 625cffc808cabf1df12fc83a55223b3fcc15be4e Mon Sep 17 00:00:00 2001
From: Akinori MUSHA <knu@i...>
Date: Tue, 26 Oct 2021 14:53:43 +0900
Subject: [ruby/digest] Abort loading if being loaded by gem/bundle pre Ruby
 3.0.3

https://github.com/ruby/digest/commit/efd76821b8
---
 ext/digest/lib/digest.rb | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/ext/digest/lib/digest.rb b/ext/digest/lib/digest.rb
index 7cb0d2c3187..c89590ee534 100644
--- a/ext/digest/lib/digest.rb
+++ b/ext/digest/lib/digest.rb
@@ -1,24 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/ext/digest/lib/digest.rb#L1
 # frozen_string_literal: false
 
-# The gem and bundle commands (except for bundle exec) first load
-# digest via openssl and then load gems, so if this is installed via
-# gem, we are overwriting the default version of digest.  Beware not
-# to break it or cause redefinition warnings.
-#
-# When we introduce incompatible changes and overwriting is not an
-# option, and given that the default version does not have security
-# defects, we may just give up and let those commands just use the
-# default version of digest.
-#
-# return if defined?(Digest) && caller_locations.any? { |l|
-#   %r{/(rubygems/gem_runner|bundler/cli)\.rb}.match?(l.path)
-# }
+if defined?(Digest) &&
+    /\A(?:2\.|3\.0\.[0-2]\z)/.match?(RUBY_VERSION) &&
+    caller_locations.any? { |l|
+      %r{/(rubygems/gem_runner|bundler/cli)\.rb}.match?(l.path)
+    }
+  # Before Ruby 3.0.3/3.1.0, the gem and bundle commands used to load
+  # the digest library before loading additionally installed gems, so
+  # you will get constant redefinition warnings and unexpected
+  # implementation overwriting if we proceed here.  Avoid that.
+  return
+end
 
 require 'digest/loader'
 
 module Digest
   # A mutex for Digest().
-  REQUIRE_MUTEX ||= Thread::Mutex.new
+  REQUIRE_MUTEX = Thread::Mutex.new
 
   def self.const_missing(name) # :nodoc:
     case name
-- 
cgit v1.2.1


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

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