From: "Conrad.Irwin (Conrad Irwin)" Date: 2013-03-23T14:50:17+09:00 Subject: [ruby-core:53659] [ruby-trunk - Bug #4487] require_relative fails in an eval'ed file Issue #4487 has been updated by Conrad.Irwin (Conrad Irwin). This bug also affects pry: https://github.com/pry/pry/issues/880. Our use-case is slightly different because we are doing TOPLEVEL_BINDING.eval("some code", "/absolute/path.rb"). I think that when an absolute path is set in eval, then require_relative should use it. ---------------------------------------- Bug #4487: require_relative fails in an eval'ed file https://bugs.ruby-lang.org/issues/4487#change-37839 Author: rogerdpack (Roger Pack) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: next minor 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 `
' 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 -- http://bugs.ruby-lang.org/