Project

General

Profile

Actions

Feature #4979

closed

`require 'foo'` is ambiguous when there is both foo.rb and foo.so

Added by terceiro (Antonio Terceiro) almost 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:37805]

Description

=begin

When there is both foo.rb and foo.so and a require 'foo' call is evaluated, Ruby 1.8 will load either foo.rb or foo.so depending on which order their directories are in $LOAD_PATH.

Ruby 1.8 will load the first foo.rb or foo.so it finds in the $LOAD_PATH.

Ruby 1.9 will first look for foo.rb in all directories, and only after that it will look for foo.so in all directories. This behaviour seems more consistent than the one in Ruby 1.8. It also matches the most common use case, which is foo.rb loading its sister foo.so that contains native-code implementations needed by foo.rb.

I have attached a test case that shows these different behaviours of Ruby 1.8 and Ruby 1.9.

I propose to make Ruby 1.8 work the same way as Ruby 1.9. If there is consensus about that, I can try to write a patch to backport the behaviour of Ruby 1.9 for Ruby 1.8.

=end


Files

ruby-require.tar.gz (557 Bytes) ruby-require.tar.gz terceiro (Antonio Terceiro), 07/06/2011 03:29 AM
noname (500 Bytes) noname tenderlovemaking (Aaron Patterson), 07/09/2011 02:53 AM
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 13 years ago

  • Tracker changed from Bug to Feature

Obviously this is a spec change request.

Updated by terceiro (Antonio Terceiro) almost 13 years ago

What is needed to have a decision?

Updated by tenderlovemaking (Aaron Patterson) almost 13 years ago

On Sat, Jul 09, 2011 at 01:04:08AM +0900, Antonio Terceiro wrote:

When there is both foo.rb and foo.so and a require 'foo' call is evaluated, Ruby 1.8 will load either foo.rb or foo.so depending on which order their directories are in $LOAD_PATH.

Ruby 1.8 will load the first foo.rb or foo.so it finds in the $LOAD_PATH.

Ruby 1.9 will first look for foo.rb in all directories, and only after that it will look for foo.so in all directories. This behaviour seems more consistent than the one in Ruby 1.8. It also matches the most common use case, which is foo.rb loading its sister foo.so that contains native-code implementations needed by foo.rb.

I have attached a test case that shows these different behaviours of Ruby 1.8 and Ruby 1.9.

I propose to make Ruby 1.8 work the same way as Ruby 1.9. If there is consensus about that, I can try to write a patch to backport the behaviour of Ruby 1.9 for Ruby 1.8.

Making this change would break 1.8 users that depend on this behavior.
Users may unknowingly depend on this behavior. Imagine someone's pain
that makes what seems like a safe upgrade (say 1.8.7-p1 to 1.8.7-p2),
and boom, my application stops working because of require behavior
change.

Contrast that with upgrading to 1.9, where the user knows some
behaviors of Ruby may have changed.

This isn't a bug, it's a behavior. Leave 1.8 as is. Let users upgrade to 1.9.

--
Aaron Patterson
http://tenderlovemaking.com/

Updated by naruse (Yui NARUSE) almost 13 years ago

  • Status changed from Open to Rejected

Ruby 1.8 won't change any more except bugs.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0