`pry foo.rb` with a `binding.pry` call in it acts weird #879

Closed
kyrylo opened this Issue Mar 10, 2013 · 2 comments

3 participants

@kyrylo
pry member
% pry foo.rb
[1] pry(main)> cat foo.rb
def a
 10
end
binding.pry
[2] pry(main)> whereami 
At the top level.
[3] pry(main)> $ a

From: (pry) @ line 1:
Owner: Object
Visibility: private
Number of lines: 3

def a
 10
end
[4] pry(main)> a
[5] pry(main)> 1 + 1
[6] pry(main)> # WTF? Where is the output?
@quark-zju

It seems that pry foo.rb makes you into a non-interactive environment. Maybe pry detect its /dev/stdout is not a PTY. This makes sense.

Since you are using binding.pry, I suggest ruby foo.rb instead of pry foo.rb.

You can get interactive environment using anything that causes an Exception:

$ pry foo.rb
[1] pry(main)> f

Exception: NameError: undefined local variable or method `f' for main:Object
--
From: (pry) @ line 4 @ level: 0 of backtrace (of 36).

    1: def a
    2:  10
    3: end
 => 4: f
...exception encountered, going interactive!
[2] pry(main)> 1+1
=> 2
[3] pry(main)> a
=> 10
@rf- rf- closed this Apr 29, 2014
@rf-
pry member

Looks fixed on master.

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