Project

General

Profile

Actions

Bug #4487

closed

require_relative fails in an eval'ed file

Added by rogerdpack (Roger Pack) over 13 years ago. Updated almost 7 years ago.

Status:
Closed
Target version:
-
ruby -v:
-
Backport:
[ruby-core:<unknown>]

Description

=begin
Hello all.

$cat eval_me1.rb
eval(File.read('eval_me2.rb'), binding, File.expand_path('./eval_me2.rb'))
$cat eval_me2.rb
require_relative 'eval_me1.rb'
$ ruby eval_me1.rb
C:/dev/ruby/faster_require/spec/eval_me2.rb:1:in require_relative': cannot infer basepath (LoadError) from C:/dev/ruby/faster_require/spec/eval_me2.rb:1:in '
from eval_me1.rb:1:in eval' from eval_me1.rb:1:in '

I suppose was assuming that if eval included a filename, then require_relative would work from within it. Perhaps I am mistaken?
Thanks!
-r
=end


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #4352: [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s)Closedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Bug #7391: Allow to use require_relative from eval and irb environmentClosedshyouhei (Shyouhei Urabe)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0