Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

before_session hook failed: Pry::CommandError: Cannot locate this method: load

Tags:

ruby

pry

Loading up the Pry REPL in a Ruby script I get this odd error:

before_session hook failed: Pry::CommandError: Cannot locate this method: load.
~/.rvm/gems/ruby-2.0.0-p195/gems/pry-0.9.12.2/lib/pry/method.rb:498:in `pry_doc_info'
(see _pry_.hooks.errors to debug)

Any idea what the problem is?

Notes: 1. The code seems to execute fine other than that cryptic message and 2. I can't find a "_pry_.hooks.errors" file

like image 549
Snowcrash Avatar asked May 23 '13 18:05

Snowcrash


1 Answers

I encountered this using Ruby 2.4.1 and Pry Stack Explorer, in a Gemfile with:

gem 'pry'
gem 'pry-rescue'
gem 'pry-stack_explorer'

On inserting the Pry Debugger, I saw:

before_session hook failed: Pry::CommandError: Cannot locate this method: load. Invoke the 'gem-install pry-doc' Pry command to get access to Ruby Core documentation.
/Users/alexharvey/.rvm/gems/ruby-2.4.1/gems/pry-0.11.3/lib/pry/method.rb:489:in `pry_doc_info'
(see _pry_.hooks.errors to debug)

Then I tried following the instructions about pry.hooks.errors:

[2] pry(#<MarkdownLint::Rule>)> puts _pry_.hooks.errors
Cannot locate this method: load. Invoke the 'gem-install pry-doc' Pry command to get access to Ruby Core documentation.
=> nil

So I just added pry-doc to my Gemfile. Then, I still had another issue. On trying to exit the debugger:

[2] pry(#<MarkdownLint::Rule>)>
when_started hook failed: NameError: uninitialized constant RubyVM::DebugInspector
/Users/alexharvey/.rvm/gems/ruby-2.4.1/gems/binding_of_caller-0.8.0/lib/binding_of_caller/mri2.rb:21:in `callers'
(see _pry_.hooks.errors to debug)

And I found I could solve that one by requesting not the latest version of debug_inspector.

In the end, to successfully use pry and pry-stack_explorer, I ended up with:

gem 'pry'
gem 'pry-rescue'
gem 'pry-stack_explorer'
gem 'pry-doc'
gem 'debug_inspector', '<= 0.0.2'
like image 119
Alex Harvey Avatar answered Sep 22 '22 06:09

Alex Harvey