Project

General

Profile

Actions

Bug #2578

closed

Requiring a relative path with an empty $LOAD_PATH raises LoadError on 1.8

Added by brixen (Brian Shirai) about 14 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]
[ruby-core:27501]

Description

=begin
Hi,

While revising the rubyspecs for Kernel#require, I noticed the following difference between 1.8 and 1.9. If $LOAD_PATH is empty, requiring a path relative to the CWD raises a LoadError on 1.8 but succeeds on 1.9. Adding any entry to $LOAD_PATH, even a nonexistent directory, causes the relative require to succeed.

I've tried searching for a ticket related to this but was unable to find one. Is this a bug in 1.8? If not a bug, could you please explain the reason for the difference.

$ cat a.rb
puts 1

$ cat b.rb
p $LOAD_PATH.clear
require './a.rb'

$ cat c.rb
p $LOAD_PATH.clear
p $LOAD_PATH << "irrelevant_dir"
require './a.rb'

$ ruby1.8.7 -v b.rb
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]
[]
b.rb:2:in `require': no such file to load -- ./a.rb (LoadError)
from b.rb:2

$ ruby1.9 -v b.rb
ruby 1.9.2dev (2009-12-16 trunk 26107) [i386-darwin9.8.0]
[]
1

$ ruby1.8.7 -v c.rb
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin9.8.0]
[]
["irrelevant_dir"]
1

$ ruby1.9 -v c.rb
ruby 1.9.2dev (2009-12-16 trunk 26107) [i386-darwin9.8.0]
[]
["irrelevant_dir"]
1

Thanks,
Brian
=end

Actions #1

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Project changed from Backport186 to Ruby master
  • Description updated (diff)
  • Status changed from Open to Closed
  • Backport set to 2.5: UNKNOWN, 2.6: UNKNOWN
Actions

Also available in: Atom PDF

Like0
Like0