Bug #1733

require does not look at current directory anymore ?

Added by Chauk-Mean (Chauk-Mean Proum) almost 3 years ago. Updated about 1 year ago.

[ruby-core:24153]
Status:Rejected Start date:07/06/2009
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:core
Target version:2.0.0
ruby -v:ruby 1.9.2dev (2009-07-03 trunk 23939)

Description

In ruby-1.9 trunk, the behaviour of require has changed.
Require does not look at the current directory anymore.
Is this intentional ?

$ cat a.rb
puts "Hello World"

$ cat b.rb
require 'a'
puts "Goodbye World"

$ ruby -v b.rb
ruby 1.9.2dev (2009-07-03 trunk 23939) [i386-mingw32]
b.rb:1:in `require': no such file to load -- a (LoadError)
        from b.rb:1:in `<main>'

Replacing require 'a' with require './a' or require_relative 'a' works.
But this introduces incompatibility issues with code that works with ruby-1.8 and ruby-1.9.1-p129.

History

Updated by matz (Yukihiro Matsumoto) almost 3 years ago

Hi,

In message "Re: [ruby-core:24153] [Bug #1733] require does not look at current directory anymore ?"
    on Mon, 6 Jul 2009 01:53:31 +0900, Chauk-Mean Proum <redmine@ruby-lang.org> writes:

|In ruby-1.9 trunk, the behaviour of require has changed.
|Require does not look at the current directory anymore.
|Is this intentional ?

Yes, there was a security risk.

							matz.

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

Hi,

At Mon, 6 Jul 2009 01:53:31 +0900,
Chauk-Mean Proum wrote in [ruby-core:24153]:
> Replacing require 'a' with require './a' or require_relative
> 'a' works.
> But this introduces incompatibility issues with code that
> works with ruby-1.8 and ruby-1.9.1-p129.

In what cases do you need it in the load path?

Command line option -I. or environment variable RUBYLIB="."
can't help you?

-- 
Nobu Nakada

Updated by Chauk-Mean (Chauk-Mean Proum) almost 3 years ago

Matz, thanks for the explanation/clarification.

Nobu, the RUBYLIB environment variable is a good enough solution. Thanks.

Updated by yugui (Yuki Sonoda) almost 3 years ago

  • Status changed from Open to Rejected

Also available in: Atom PDF