How to Use the Debugger with Ruby 2.0

How to use the debugger with Ruby 2.0?

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.

Is there a pry debug setup that works with ruby 2.0?

pry-byebug 1.1.1+ works with ruby 2.0.0-p247. It's a fork of pry-debugger & works with ruby 2.0+ only.

gem 'pry-byebug'

https://github.com/deivid-rodriguez/pry-byebug

updated with version numbers

Debugging in ruby 1.9

Note: this answer was correct but is now out of date. See the below correct answer. TL;DR: use 'debugger' now.

ruby-debug is now available with Ruby 1.9.x. See http://www.github.com/mark-moseley

To install (using gem on 1.9 Ruby installation):

gem install ruby-debug19

(with perhaps the necessary 'sudo' in front of it).

Ruby debug is stepping into rather than stepping over

Debugger does not yet fully support Ruby 2.0, and one of the issues is that next incorrectly acts like step. You’ll have to wait till the issue is fixed for it to work correctly, or use an alternative debugger such as Byebug.

Using Rails4.1.1 and Ruby 2.0.0, binding.pry's terminal output is sometimes empty

Are you using pry-debugger? If so, with Ruby 2+, you may want to change to pry-byebug. There is some kind of linecache incompatibility between Ruby 1.9 & 2.x, and byebug fixes that.



Related Topics



Leave a reply



Submit