From: Hiroshi NAKAMURA Date: 2011-05-18T16:57:35+09:00 Subject: [ruby-core:36307] [Ruby 1.9 - Bug #4255][Open] When on a case-insensitive filesystem, "loaded features" search in require should ignore case Issue #4255 has been updated by Hiroshi NAKAMURA. Category set to core Status changed from Closed to Open I think this issue involuntarily interpreted and "fixed". For 1.9, I propose reverting r30508 before 1.9.3 (it's not yet released.) The issue Charles stated is indeed the problem on 1.8 (I only checked 1.8.7, though). C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mswin32] C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>copy con foo.rb p :LOADED ^Z C:\Users\nahi\Documents\tools\ruby-1.8.7-p302-i386-mswin32\bin>ruby -I. -e "requ ire 'foo'; require 'Foo'; require 'FOO'; require 'foo.rb'; p $LOADED_FEATURES" :LOADED :LOADED :LOADED ["enumerator.so", "foo.rb", "Foo.rb", "FOO.rb"] It loads 3 times, not 1 time nor 4 times. (I know what's happening inside.) But 1.9 does not have this problem since it pushes expanded path to $LOADED_FEATURES. C:\Users\nahi\Documents\tools\ruby-1.9.2-p0-i386-mswin32\bin>ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-mswin32] C:\Users\nahi\Documents\tools\ruby-1.9.2-p0-i386-mswin32\bin>copy con foo.rb p :LOADED ^Z C:\Users\nahi\Documents\tools\ruby-1.9.2-p0-i386-mswin32\bin>ruby -I. -e "requir e 'foo'; require 'Foo'; require 'FOO'; require 'foo.rb'; p $LOADED_FEATURES" :LOADED ["enumerator.so", "C:/Users/nahi/Documents/tools/ruby-1.9.2-p0-i386-mswin32/lib/ ruby/1.9.1/i386-mswin32/enc/encdb.so", "C:/Users/nahi/Documents/tools/ruby-1.9.2 -p0-i386-mswin32/lib/ruby/1.9.1/i386-mswin32/enc/shift_jis.so", "C:/Users/nahi/D ocuments/tools/ruby-1.9.2-p0-i386-mswin32/lib/ruby/1.9.1/i386-mswin32/enc/trans/ transdb.so", "C:/Users/nahi/Documents/tools/ruby-1.9.2-p0-i386-mswin32/bin/foo.r b"] It loads only 1 time. See 1.9.2 revision 29036 < r30508. Even without r30508, 1.9 only loads 1 time even if user gives various case combinations of a file to 'require'. Since the "fix" r30508 fixed the problem which did not exist, let's revert it. We can imagine contrived example, such as 'if rubygems inserts crafted String to $" by itself?' but we should "fix" it at that time, based on concrete examples of the problem. Given no objection, I'm going to revert it in a week. (Say NO now! 1.9.3 is coming :-) Aside from this, we might need this case-insensitivity fix for 1.8. Is it too late? ---------------------------------------- Bug #4255: When on a case-insensitive filesystem, "loaded features" search in require should ignore case http://redmine.ruby-lang.org/issues/4255 Author: Charles Nutter Status: Open Priority: Normal Assignee: Category: core Target version: ruby -v: Any version =begin This should not re-load the same library when running on a system with case-insensitive filenames: require 'blah' require 'BLAH' The resource in question has been loaded, and should not be reloaded again, even if it is attempted with a differing case. The above case seems contrived, but we have run into many real-world cases of this problem: * win32 APIs return paths with the drive name capitalized. Many libraries that manipulate load paths use lower-case drive names. (C: versus c:) * User code that adds load path entries at command-line or in script can easily differ in case * Typos in path names that introduce case differences will quietly work but cause double-requires. These may or may not be detected. A specific case in JRuby caused a series of files to be loaded twice, ultimately resulting in an alias chain looping back on itself (!!!). This is an extremely difficult case to debug, but very easy to reproduce. I propose that Ruby 1.9 (and ideally Ruby 1.8, since I consider this a bug and not a feature) should treat "loaded features" $" entries sourced from a case-insensitive filesystem with a case-insensitive comparison. =end -- http://redmine.ruby-lang.org