Skip to content

Commit 2432b3c

Browse files
hsbtclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 46d0e45 commit 2432b3c

1 file changed

Lines changed: 4 additions & 18 deletions

File tree

lib/pathname.rb

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,14 @@
1010
# For documentation, see class Pathname.
1111
#
1212

13-
if defined?(::Pathname) # Clear builtin Pathname
14-
# :stopdoc:
15-
class ::Object
16-
remove_const :Pathname
17-
end
13+
return if RUBY_VERSION >= '4.1'
1814

19-
# Remove module_function Pathname
20-
class << ::Kernel
21-
undef Pathname
22-
end
23-
module ::Kernel
24-
undef Pathname
25-
end
15+
unless RUBY_VERSION >= '4'
16+
require 'pathname.so' if RUBY_ENGINE == 'ruby'
2617

27-
$".delete('pathname.so')
28-
# :startdoc:
18+
require_relative 'pathname_builtin'
2919
end
3020

31-
require 'pathname.so' if RUBY_ENGINE == 'ruby'
32-
33-
require_relative 'pathname_builtin'
34-
3521
class Pathname # * Find *
3622
#
3723
# Iterates over the directory tree in a depth first manner, yielding a

0 commit comments

Comments
 (0)