Hello,

> =A0$cat eval_me1.rb
> =A0eval(File.read('eval_me2.rb'), binding, File.expand_path('./eval_me2.r=
b'))
> =A0$cat eval_me2.rb
> =A0require_relative 'eval_me1.rb'
> =A0$ ruby eval_me1.rb
> =A0C:/dev/ruby/faster_require/spec/eval_me2.rb:1:in `require_relative': c=
annot infer basepath (LoadError)
> =A0 =A0 =A0 =A0from C:/dev/ruby/faster_require/spec/eval_me2.rb:1:in `<ma=
in>'
> =A0 =A0 =A0 =A0from eval_me1.rb:1:in `eval'
> =A0 =A0 =A0 =A0from eval_me1.rb:1:in `<main>'
>
> I suppose was assuming that if eval included a filename, then require_rel=
ative 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 =3D rb_iseq_compile(src, rb_str_new2(file), INT2FIX(line));
+	iseqval =3D 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--;

--=20
Yusuke Endoh <mame / tsg.ne.jp>