From: Charles Oliver Nutter Date: 2011-03-10T06:35:55+09:00 Subject: [ruby-core:35473] Re: MRI silently handles .so files as Ruby sources On Wed, Mar 9, 2011 at 2:59 PM, Simone Carletti wrote: > Hello, > today I noticed that if you have a file called filename.so.rb and you try to > require it without specifying the extension, MRI silently understands that > it isn't a .so file, will load the content and treat it as Ruby source. >> >> # filename.so.rb >> puts __FILE__ >> # somefile.rb >> require 'filename.so' >> # => /../../filename.so.rb > > Other interpreters handle the case in a different way. > For example, JRuby won't load the file because it looks for a Ruby extension > in a file called filename.so. > See��http://jira.codehaus.org/browse/JRUBY-5569 > I had a small chat with��Charles Oliver Nutter (you can read the comments in > the JIRA ticket) and I'm curious to know if the way MRI works should be > considered a bug, a coincidence or a feature. > Thanks, Just when I thought I knew all load-searching oddities :) If you look at the JRuby bug you'll see that it's a very specific case and I show several scenarios that either work or don't work... * Only fails over for "extension" extensions like .so or .bundle...does not fail over for things like foo.rb.rb or foo.rb.so * Appears to do a search for both .rb and if the original filename doesn't work * Does not fail over to "extension" extensions that are not appropriate for current platform, like .so.so on OS X I think it's confusing and unpredictable and would just as soon have the logic be "if it ends with an extension extension, only search extension extensions." - Charlie