edit fails to reload if require_relative is used #880

ghost opened this Issue Mar 11, 2013 · 6 comments


None yet
4 participants

ghost commented Mar 11, 2013


require_relative "bar"
class Foo
  def bar

Edit a method:
edit Foo#bar

On reload, Pry fails to reload the file because the base path cannot be inferred by require_relative. I think the file needs to be re-evaluated with __FILE__ set to whatever file the class Foo is in.

EDIT: typo's


ConradIrwin commented Mar 23, 2013

This is a ruby bug: http://bugs.ruby-lang.org/issues/4487. We can probably work around it by using load instead of eval.


ghost commented Mar 23, 2013

@ConradIrwin Thanks <3

radarek commented Sep 13, 2013

I doesn't work for me. Maybe it is regression?

$ cat a.rb 
require_relative 'b'

class A
  def foo
    puts 'foo!'

$ cat b.rb 
class B

$ pry -r ./a.rb
[1] pry(main)> edit A#foo
LoadError: cannot infer basepath
from /private/tmp/foo/a.rb:1:in `require_relative'
[2] pry(main)> RUBY_VERSION
=> "2.0.0"
[3] pry(main)> RUBY_PATCHLEVEL
=> 195
[4] pry(main)> Pry::VERSION
=> ""

Does not work for me either.

[1] pry(#<Comments::Comment>)> edit --method
LoadError: cannot infer basepath
comment.rb:45:in `require_relative'
[2] pry(#<Comments::Comment>)> RUBY_VERSION
=> "2.0.0"
[3] pry(#<Comments::Comment>)> RUBY_PATCHLEVEL
=> 247
[4] pry(#<Comments::Comment>)> Pry::VERSION
=> ""

rf- commented Nov 13, 2013

The fix is actually only in master, not in a released gem. We could cherry-pick it to the 0.9.12 branch, but we should finally release 1.0 pretty soon anyway.


ghost commented Nov 13, 2013

@rf- 1.0 soon ? =/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment