Project

General

Profile

Actions

Bug #21091

closed

recursive require not detected on case insensitive filesystem

Added by rrotter (Ryan Rotter) 26 days ago. Updated 26 days ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24]
[ruby-core:120797]

Description

On case insensitive filesystems requireing a file from itself causes the file to be required twice if the initial require and the require inside the file have different capitalization.

I expect the second require to return false, and not execute the file a second time.

~ % cat /tmp/foo.rb
puts "loading #{__FILE__}"
require "/tmp/foo"
SOME_GLOBAL = "foobar".freeze
~ % ruby -r/tmp/FOO
loading /tmp/FOO.rb
loading /tmp/foo.rb
/tmp/FOO.rb:3: warning: already initialized constant SOME_GLOBAL
/tmp/foo.rb:3: warning: previous definition of SOME_GLOBAL was here

This is on macOS 15.1.1, using the default case-insensitive APFS, and ruby 3.4.1.

Updated by shyouhei (Shyouhei Urabe) 26 days ago

  • Status changed from Open to Third Party's Issue

There's not much thing we can do to this situation. Your file system opted to provide us multiple file paths for an identical content. That's how your operating system is designed to work. Ruby doesn't prevent you from shooting yourself in foot.

Updated by rrotter (Ryan Rotter) 26 days ago ยท Edited

I would agree with your assessment if requiring both names of the same file sequentially loaded it twice,
but ruby is apparently detecting and handling this when the two requires are not recursive. The following code works as expected:

# returns true
require '/some/file'
# returns false
require '/some/FILE'
Actions

Also available in: Atom PDF

Like0
Like0Like0