How to use the debugger with Ruby 2.0?

家住魔仙堡 提交于 2019-11-27 04:29:11

问题


I know the debugger gem is not and never will be compatible with ruby 2.0 per "officially support ruby 2.X".

In the changelog of Ruby 2.0 is:

Debug support

DTrace support, which enables run-time diagnosis in

production TracePoint, which is an improved tracing API

Is there something out of the box for debugging with Ruby 2.0? Can somebody explain this to me?


回答1:


The debugger gem can be used but it still has issues.

Install byebug which was written for Ruby 2.0 debugging.

For breakpoints, use the byebug command in your code instead of debugger.




回答2:


Version 1.4.0 of the debugger gem now installs without problems. 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.




回答3:


Use pry:

gem install pry  
gem install pry-debugger

See "Debugging Ruby With Pry".



来源:https://stackoverflow.com/questions/15200165/how-to-use-the-debugger-with-ruby-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!