作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
在 Ruby 脚本中加载 Pry REPL 我得到了这个奇怪的错误:
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)
知道问题出在哪里吗?
注意事项:1.除了那个神秘的消息之外,代码似乎执行得很好,并且2. 我找不到“_pry_.hooks.errors
”文件
最佳答案
我在 Gemfile 中使用 Ruby 2.4.1 和 Pry Stack Explorer 遇到了这个问题:
gem 'pry'
gem 'pry-rescue'
gem 'pry-stack_explorer'
在插入 Pry Debugger 时,我看到:
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)
然后我尝试按照有关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
所以我刚刚将 pry-doc 添加到我的 Gemfile 中。然后,我还有另一个问题。尝试退出调试器时:
[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)
我发现我可以通过请求不是最新版本的 debug_inspector 来解决这个问题。
最后,为了成功使用 pry 和 pry-stack_explorer,我得到了:
gem 'pry'
gem 'pry-rescue'
gem 'pry-stack_explorer'
gem 'pry-doc'
gem 'debug_inspector', '<= 0.0.2'
关于ruby - before_session Hook 失败:Pry::CommandError:找不到此方法:加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16721405/
在 Ruby 脚本中加载 Pry REPL 我得到了这个奇怪的错误: before_session hook failed: Pry::CommandError: Cannot locate this
我是一名优秀的程序员,十分优秀!