---------- Forwarded message ----------
From: Roger Pack <rogerp...@gmail.com>
Date: Wed, Mar 9, 2011 at 4:12 PM
Subject: Fwd: You rogerp...@gmail.com are not member (ruby-core ML)
To: roger...@gmail.com
---------- Forwarded message ----------
From: <ruby-co...@ruby-lang.org>
Date: Wed, Mar 9, 2011 at 11:25 AM
Subject: You rogerp...@gmail.com are not member (ruby-core ML)
To: rogerp...@gmail.com
You are not a member of this mailing list <ruby...@ruby-lang.org>.
If you want to know the general guide of this list, please send an email
with the body (case-insensitive):
# guide
to the address
Note that the mail should not be encoded in base64.
Status changed from Open to Assigned
Assignee set to Yusuke Endoh
----------------------------------------
Bug #4487: require_relative fails in an eval'ed file
http://redmine.ruby-lang.org/issues/4487
Author: Roger Pack
Status: Assigned
Priority: Normal
Assignee: Yusuke Endoh
Category:
Target version:
ruby -v: ruby 1.9.3dev (2011-03-04 trunk 31024) [i386-mingw32]
=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 `<main>'
from eval_me1.rb:1:in `eval'
from eval_me1.rb:1:in `<main>'
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
> $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 `<main>'
> from eval_me1.rb:1:in `eval'
> from eval_me1.rb:1:in `<main>'
>
> I suppose was assuming that if eval included a filename, then require_relative would work from within it. Perhaps I am mistaken?
I think your expectation is reasonable, though I personally dislike
the eval's feature to fake filepath.
The following patch makes require_relative use the given file path.
I'm afraid if I should include this patch in 1.9.3 because I can't
estimate the impact of this patch. What do you think?
diff --git a/vm_eval.c b/vm_eval.c
index 7df7f5f..3710401 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1007,7 +1007,7 @@ eval_string_with_cref(VALUE self, VALUE src,
VALUE scope, NODE *cref, const char
/* make eval iseq */
th->parse_in_eval++;
th->mild_compile_error++;
- iseqval = rb_iseq_compile(src, rb_str_new2(file), INT2FIX(line));
+ iseqval = rb_iseq_compile_with_option(src, rb_str_new2(file),
rb_str_new2(file), INT2FIX(line), Qnil);
th->mild_compile_error--;
th->parse_in_eval--;
--
Yusuke Endoh <ma...@tsg.ne.jp>
Assignee changed from Yusuke Endoh to Yukihiro Matsumoto
Related to #4352.
I need matz's judgment.
--
Yusuke Endoh <ma...@tsg.ne.jp>
----------------------------------------
Bug #4487: require_relative fails in an eval'ed file
http://redmine.ruby-lang.org/issues/4487
Author: Roger Pack
Status: Assigned
Priority: Normal
Assignee: Yukihiro Matsumoto
Category:
Target version:
ruby -v: -
=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 `<main>'
from eval_me1.rb:1:in `eval'
from eval_me1.rb:1:in `<main>'
I suppose was assuming that if eval included a filename, then require_relative would work from within it. Perhaps I am mistaken?