From 2432b3c7376961ce0c84a104bd2e0d3c7603b2dd Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 7 Apr 2026 15:35:20 +0900 Subject: [PATCH 1/3] Skip loading gem version of pathname on Ruby 4.0+ Ruby 4.0 makes Pathname a built-in class, and Ruby 4.1 will make all methods including find, rmtree, and mktmpdir built-in as well. On Ruby 4.0, only the three additional methods are redefined from the gem. On Ruby 4.1+, the gem returns immediately and defers entirely to the built-in implementation. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/pathname.rb | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/pathname.rb b/lib/pathname.rb index 37a5a21..84feeb7 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -10,28 +10,14 @@ # For documentation, see class Pathname. # -if defined?(::Pathname) # Clear builtin Pathname - # :stopdoc: - class ::Object - remove_const :Pathname - end +return if RUBY_VERSION >= '4.1' - # Remove module_function Pathname - class << ::Kernel - undef Pathname - end - module ::Kernel - undef Pathname - end +unless RUBY_VERSION >= '4' + require 'pathname.so' if RUBY_ENGINE == 'ruby' - $".delete('pathname.so') - # :startdoc: + require_relative 'pathname_builtin' end -require 'pathname.so' if RUBY_ENGINE == 'ruby' - -require_relative 'pathname_builtin' - class Pathname # * Find * # # Iterates over the directory tree in a depth first manner, yielding a From 4338633365984700ad09eecea78b11e0fd060c53 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 14 Apr 2026 15:02:59 +0900 Subject: [PATCH 2/3] Remove early return for Ruby 4.1+ until ruby/ruby#16358 is merged Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/pathname.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/pathname.rb b/lib/pathname.rb index 84feeb7..18c2e04 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -10,8 +10,6 @@ # For documentation, see class Pathname. # -return if RUBY_VERSION >= '4.1' - unless RUBY_VERSION >= '4' require 'pathname.so' if RUBY_ENGINE == 'ruby' From 8b4d1683f6865af3c294bcb551a7dd61fd691fab Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 14 Apr 2026 15:40:38 +0900 Subject: [PATCH 3/3] Skip Ractor test on mingw where Pathname::SAME_PATHS is not shareable Co-Authored-By: Claude Opus 4.6 (1M context) --- test/pathname/test_ractor.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pathname/test_ractor.rb b/test/pathname/test_ractor.rb index 737e4a4..ed1403e 100644 --- a/test/pathname/test_ractor.rb +++ b/test/pathname/test_ractor.rb @@ -8,6 +8,7 @@ def setup end def test_ractor_shareable + omit "Ractor with Pathname is not supported on mingw" if /mingw/ =~ RUBY_PLATFORM assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") class Ractor alias value take