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
Ruby on Rails Best Practices - Big Controller VS Small Controller
Convert To/From Datetime and Time in Ruby
Difference Between Ruby and Ruby on Rails
Dry Ruby Initialization With Hash Argument
How to 'Bundle Install' When Your Gemfile Requires an Older Version of Bundler
How to Deal With the Sum of Rounded Percentage Not Being 100
How to Use Active Support Core Extensions
Ruby Regular Expression to Match a Url
Overriding a Module Method from a Gem in Rails
Ruby on Rails - Access Controller Variable from Model
Uploading Multiple Files With Paperclip
Rails 3 Disabling Session Cookies
Block Comments in HTML.Erb Templates in Rails
Ruby - Access Multidimensional Hash and Avoid Access Nil Object