pry-stack_explorer icon indicating copy to clipboard operation
pry-stack_explorer copied to clipboard

when_started hook interaction issue with awesome_print

Open onyxraven opened this issue 10 years ago • 15 comments

After upgrading to pry 0.10, I started seeing when_started hook failed: NoMethodError: private method eval' called for nil:NilClass /usr/local/opt/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/pry-stack_explorer-0.4.9.1/lib/pry-stack_explorer.rb:109:in bindings_equal?' after every command.

I created a new gemfile to test from clean with just

source 'https://rubygems.org'
gem 'pry'
gem 'pry-stack_explorer'

It did not exhibit the behavior. After installing awesome_print (as recommended by pry), the error came back.

Using awesome_print 1.2.0
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using coderay 1.1.0
Using method_source 0.8.2
Using slop 3.6.0
Using pry 0.10.1
Using pry-stack_explorer 0.4.9.1
Using bundler 1.6.0

I'll follow up with awesome_print as well, but wanted to bring up the error here in case it was an interaction on this side.

onyxraven avatar Sep 10 '14 16:09 onyxraven

This is only with awesome print?

banister avatar Sep 10 '14 20:09 banister

How are you setting up aweome_print ?

banister avatar Sep 10 '14 20:09 banister

Yep, ok. Looks like the config I inherited.

# == PLUGINS ===
# awesome_print gem: great syntax colorized printing
# look at ~/.aprc for more settings for awesome_print
begin
  require 'awesome_print'
  # The following line enables awesome_print for all pry output,
  # and it also enables paging
  AwesomePrint.pry!
  Pry.config.print = proc {|output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output)}

  # If you want awesome_print without automatic pagination, use the line below
  # Pry.config.print = proc { |output, value| output.puts value.ai }
rescue LoadError => err
  puts "gem install awesome_print  # <-- highly recommended"
end

removing the Pry.config.print line fixes the issue - I'm not even sure what it does.

Not an issue afterall.

onyxraven avatar Sep 10 '14 21:09 onyxraven

Btw, thats the config they have in https://github.com/pry/pry/wiki/FAQ#awesome_print

onyxraven avatar Sep 10 '14 21:09 onyxraven

I'm having the same issue. And I would like to keep the print line, because it enables an optional pry.pager (less) within awesome print output.

Pry.config.print = proc {|output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output)}

Do you have any suggesting how to fix that? I tried to look into bindings_equal? method, but it's too complex for me to understand without reading all of the source code.

scarfacedeb avatar Oct 02 '14 13:10 scarfacedeb

I get the same issue here without having awesome print installed at all. Did anyone else see some other cause?

CyborgMaster avatar Nov 15 '14 02:11 CyborgMaster

I'm also seeing this, without awesome print... totally clean install of ruby 1.9.3. I don't have dotfiles for pry or awesome.

$ rbenv install 1.9.3-p551
Downloading yaml-0.1.6.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749
Installing yaml-0.1.6...
Installed yaml-0.1.6 to /home/cprice/.rbenv/versions/1.9.3-p551

Downloading ruby-1.9.3-p551.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/bb5be55cd1f49c95bb05b6f587701376b53d310eb1bb7c76fbd445a1c75b51e8
Installing ruby-1.9.3-p551...
Installed ruby-1.9.3-p551 to /home/cprice/.rbenv/versions/1.9.3-p551

$ rbenv shell 1.9.3-p551
$ gem install pry-stack_explorer
Fetching: debug_inspector-0.0.2.gem (100%)
Building native extensions.  This could take a while...
Fetching: binding_of_caller-0.7.2.gem (100%)
Building native extensions.  This could take a while...
Fetching: coderay-1.1.0.gem (100%)
Fetching: slop-3.6.0.gem (100%)
Fetching: method_source-0.8.2.gem (100%)
Fetching: pry-0.10.1.gem (100%)
Fetching: pry-stack_explorer-0.4.9.1.gem (100%)
Successfully installed debug_inspector-0.0.2
Successfully installed binding_of_caller-0.7.2
Successfully installed coderay-1.1.0
Successfully installed slop-3.6.0
Successfully installed method_source-0.8.2
Successfully installed pry-0.10.1
Successfully installed pry-stack_explorer-0.4.9.1
7 gems installed
Installing ri documentation for debug_inspector-0.0.2...
Installing ri documentation for binding_of_caller-0.7.2...
Installing ri documentation for coderay-1.1.0...
Installing ri documentation for slop-3.6.0...
Installing ri documentation for method_source-0.8.2...
Installing ri documentation for pry-0.10.1...
Installing ri documentation for pry-stack_explorer-0.4.9.1...
Installing RDoc documentation for debug_inspector-0.0.2...
Installing RDoc documentation for binding_of_caller-0.7.2...
Installing RDoc documentation for coderay-1.1.0...
Installing RDoc documentation for slop-3.6.0...
Installing RDoc documentation for method_source-0.8.2...
Installing RDoc documentation for pry-0.10.1...
Installing RDoc documentation for pry-stack_explorer-0.4.9.1...

$ gem list

*** LOCAL GEMS ***

bigdecimal (1.1.0)
binding_of_caller (0.7.2)
coderay (1.1.0)
debug_inspector (0.0.2)
io-console (0.3)
json (1.5.5)
method_source (0.8.2)
minitest (2.5.1)
pry (0.10.1)
pry-stack_explorer (0.4.9.1)
rake (0.9.2.2)
rdoc (3.9.5)
slop (3.6.0)

$ irb
irb(main):001:0> require 'pry'
=> true
irb(main):002:0> binding.pry

Frame number: 0/13
[1] pry(main)> show-stack
when_started hook failed: NoMethodError: private method `eval' called for nil:NilClass
/home/cprice/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/pry-stack_explorer-0.4.9.1/lib/pry-stack_explorer.rb:109:in `bindings_equal?'
(see _pry_.hooks.errors to debug)

Showing all accessible frames in stack (14 in total):
--
=> #0  irb_binding <Object#irb_binding()>
   #1 [method]  evaluate <IRB::WorkSpace#evaluate(context, statements, file=?, line=?)>
   #2 [method]  evaluate <IRB::Context#evaluate(line, line_no)>
   #3 [block]   block (2 levels) in eval_input <IRB::Irb#eval_input()>
   #4 [method]  signal_status <IRB::Irb#signal_status(status)>
   #5 [block]   block in eval_input <IRB::Irb#eval_input()>
   #6 [block]   block (2 levels) in each_top_level_statement <RubyLex#each_top_level_statement()>
   #7 [block]   block in each_top_level_statement <RubyLex#each_top_level_statement()>
   #8 [method]  each_top_level_statement <RubyLex#each_top_level_statement()>
   #9 [method]  eval_input <IRB::Irb#eval_input()>
   #10 [block]   block in start <IRB.start(ap_path=?)>
   #11 [method]  start <IRB.start(ap_path=?)>
   #12 [eval]    <main> 
   #13 [top]     <main> 
[2] pry(main)>

cprice404 avatar Dec 23 '14 17:12 cprice404

I'm seeing this issue without awesome_print, just a pretty clean pry install with pry-byebug, pry-stack_explorer, and pry_doc:

ruby-2.1.5@pryceless_tools ➜  pryceless_tools  pry
[1] pry(main)> show-stack
when_started hook failed: NoMethodError: private method `eval' called for nil:NilClass
/Users/bzittlau/.rvm/gems/ruby-2.1.5@pryceless_tools/gems/pry-stack_explorer-0.4.9.1/lib/pry-stack_explorer.rb:109:in `bindings_equal?'
(see _pry_.hooks.errors to debug)

Showing all accessible frames in stack (7 in total):
--
=> #0  __pry__ <self.__pry__(UNKNOWN) (undefined method)>
   #1 [block]   block in <top (required)>
   #2 [block]   block in parse_options <Pry::CLI.parse_options(args=?)>
   #3 [method]  parse_options <Pry::CLI.parse_options(args=?)>
   #4 [top]     <top (required)>
   #5 [eval]    <main>
   #6 [main]    <main>

benzittlau avatar Jan 18 '15 18:01 benzittlau

Experimenting across some versions of pry and stack_explorer it looks like this is an issue with any => 0.10 version of pry. It still works for me with the following Gemfile:

source 'https://rubygems.org'

gem 'pry', '~> 0.9.12'
gem 'pry-stack_explorer'

benzittlau avatar Jan 18 '15 19:01 benzittlau

I'm running into this issue with the following:

pry (0.10.1)
  * pry-byebug (3.1.0)
  * pry-doc (0.8.0)
  * pry-rails (0.3.4)
  * pry-rescue (1.4.2)
  * pry-stack_explorer (0.4.9.2)

No awesome_print, or .pryrc.

maxkwallace avatar Nov 12 '15 15:11 maxkwallace

Also, experiencing the same issue, with same gem + versions as @maxkwallace noted above.

aeberlin avatar Dec 07 '15 14:12 aeberlin

Follow-up: It seems that pry-rescue is auto-requiring pry-stack_explorer, regardless of what the Gemfile specified in the require: foo setting. I'll investigate more later, but hope this helps other people.

aeberlin avatar Dec 07 '15 15:12 aeberlin

Seeing the same thing

taylorannberg avatar Feb 18 '16 04:02 taylorannberg

I'm also seeing this with only stack_explorer and rescue plugins.

IronSavior avatar Jul 09 '16 06:07 IronSavior

Thanks guys, i'll take a look

banister avatar Jul 09 '16 21:07 banister

Old ticket, can close

onyxraven avatar Jun 20 '23 20:06 onyxraven