[英]How to use the debugger with Ruby 2.0?
I know the debugger gem is not and never will be compatible with ruby 2.0 per " officially support ruby 2.X ".我知道调试器 gem 不是也永远不会与“ 正式支持 ruby 2.X ”的 ruby 2.0 兼容。
In the changelog of Ruby 2.0 is:在 Ruby 2.0 的更新日志中是:
Debug support
调试支持
DTrace support, which enables run-time diagnosis in
DTrace 支持,可在
production TracePoint, which is an improved tracing API
生产 TracePoint,这是一个改进的跟踪 API
Is there something out of the box for debugging with Ruby 2.0?是否有开箱即用的 Ruby 2.0 调试功能? Can somebody explain this to me?
有人可以向我解释一下吗?
Version 1.4.0 of the debugger gem now installs without problems. 调试器gem的1.4.0版现在安装没有问题。 There are still some issues but this should be fixed soon.
仍有一些问题,但应尽快修复。
The debugger gem does not play well with Ruby 2. Instead, install the Byebug gem that is fully compatible with Ruby 2. 调试器gem与Ruby 2不兼容。相反,安装与Ruby 2完全兼容的Byebug gem。
gem install pry
gem install pry-debugger
See " Debugging Ruby With Pry ". 请参阅“ 使用Pry调试Ruby ”。
Consider using a new Ruby debugging tool called debug.rb .考虑使用名为debug.rb的新 Ruby 调试工具。
It supports syntax highlighting and many more out-of-the-box.它支持语法高亮和更多开箱即用的功能。
Also, it is worth mentioning that it is developed by the Ruby core team.此外,值得一提的是,它是由 Ruby 核心团队开发的。
Just place binding.break
anywhere in your codebase.只需将
binding.break
放在代码库中的任何位置。
Here is an example:下面是一个例子:
Also, it is a default Rails debugger starting from version 7 .此外,它是从版本 7 开始的默认 Rails 调试器。
Notes:笔记:
require 'debug'
require 'debug'
q # quit command
Sources:资料来源:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.