Skip to content

Instantly share code, notes, and snippets.

@hsbt
Created November 12, 2019 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsbt/46dca58367ee37b68ca3bfcaa9f75815 to your computer and use it in GitHub Desktop.
Save hsbt/46dca58367ee37b68ca3bfcaa9f75815 to your computer and use it in GitHub Desktop.
commit 0cf884df64c307d4c9322e1ad7eb28f9e8efec31 (HEAD -> backport-ruby-core)
Author: Hiroshi SHIBATA <hsbt@ruby-lang.org>
Date: 2019-11-12 15:44:19 +0900
Only enabled mon_owned condition with Ruby 2.5+
diff --git lib/rubygems/core_ext/kernel_require.rb lib/rubygems/core_ext/kernel_require.rb
index d2bcc508e5..0be5172040 100644
--- lib/rubygems/core_ext/kernel_require.rb
+++ lib/rubygems/core_ext/kernel_require.rb
@@ -32,7 +32,9 @@ module Kernel
# that file has already been loaded is preserved.
def require(path)
- monitor_owned = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?
+ if RUBY_PLATFORM >= '2.5'
+ monitor_owned = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?
+ end
RUBYGEMS_ACTIVATION_MONITOR.enter
path = path.to_path if path.respond_to? :to_path
@@ -167,9 +169,11 @@ module Kernel
raise load_error
ensure
- if monitor_owned != (ow = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?)
- STDERR.puts [$$, Thread.current, $!, $!.backtrace].inspect if $!
- raise "CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before #{monitor_owned} -> after #{ow}"
+ if RUBY_VERSION >= "2.5"
+ if monitor_owned != (ow = RUBYGEMS_ACTIVATION_MONITOR.mon_owned?)
+ STDERR.puts [$$, Thread.current, $!, $!.backtrace].inspect if $!
+ raise "CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before #{monitor_owned} -> after #{ow}"
+ end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment