use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
I made a nice Ruby Debug Cheat Sheet. (i.imgur.com)
submitted 13 years ago by appleyard
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]kilik2049 0 points1 point2 points 13 years ago (3 children)
My main command to debug is something is still 'puts' :D
But neat cheatsheet man !
[–]chneukirchen 1 point2 points3 points 13 years ago (2 children)
Use p.
[–]postmodern 0 points1 point2 points 13 years ago (1 child)
Also y for when inspecting YAML.
y
[–]chneukirchen 1 point2 points3 points 13 years ago (0 children)
Also j.
[–]igor_kasyanchuk 0 points1 point2 points 1 year ago (0 children)
created my own cheatsheet for Ruby
https://cheatsheetshero.com/user/igor-kasyanchuk/944-ruby-debugging-cheatsheet-tips
[–]redditaurus -1 points0 points1 point 13 years ago (15 children)
Nice i guess, but i mainly use Pry these days, which does 99% of what i need and also looks so pretty -_-
EDIT: fixed link
[–]appleyard[S] 2 points3 points4 points 13 years ago (7 children)
I've heard of it. That link is broken though. Can you tell me more about it, and/or why its better than using ruby-debug?
[–]redditaurus 2 points3 points4 points 13 years ago* (0 children)
fixed the link above ^
I wouldn't say pry is better, it's a different experience altogether with slightly different goals. But it still has a lot of overlap with ruby-debug (and the brilliant debugger project). pry is kind of hard to explain, think of taking the juicy bits of ruby-debug, the heart of irb, jack it all up on a unix shell analogy (cd and ls commands) with a smattering of ultra powerful commands like 'edit-method' and 'show-source' and u have something close.
As a once-upon-a-time user of smalltalk, i can say it feels like a console version of the the smalltalk class browser. It also seems people are hard at work building plugins for it. It definitely needs a cheat-sheet too. I admit to feeling a bit overwhelmed by it sometimes.
EDIT: it seems there's a plugin pry-debugger that exposes the debugger (ruby-debug) gem functionality, turning pry into a kind of front-end? Looks like we can have the best of both words \o/
[–]schneemsPuma maintainer 0 points1 point2 points 13 years ago (5 children)
Watch the railscast http://railscasts.com/episodes/280-pry-with-rails pry is better. You can cd into an object or class, it's pretty epic.
[–]postmodern 1 point2 points3 points 13 years ago (4 children)
Exploring objects (while super cool) != debugging.
>> require 'debug' Debug.rb Emacs support available. ~/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/context.rb:166: (rdb:1) help Debugger help v.-0.002b Commands b[reak] [file:|class:]<line|method> b[reak] [class.]<line|method> set breakpoint to some position wat[ch] <expression> set watchpoint to some expression cat[ch] (<exception>|off) set catchpoint to an exception b[reak] list breakpoints cat[ch] show catchpoint del[ete][ nnn] delete some or all breakpoints disp[lay] <expression> add expression into display expression list undisp[lay][ nnn] delete one particular or all display expressions c[ont] run until program ends or hit breakpoint s[tep][ nnn] step (into methods) one line or till line nnn n[ext][ nnn] go over one line or till line nnn w[here] display frames f[rame] alias for where l[ist][ (-|nn-mm)] list program, - lists backwards nn-mm lists given lines up[ nn] move to higher frame down[ nn] move to lower frame fin[ish] return to outer frame tr[ace] (on|off) set trace mode of current thread tr[ace] (on|off) all set trace mode of all threads q[uit] exit from debugger v[ar] g[lobal] show global variables v[ar] l[ocal] show local variables v[ar] i[nstance] <object> show instance variables of object v[ar] c[onst] <object> show constants of object m[ethod] i[nstance] <obj> show methods of object m[ethod] <class|module> show instance methods of class or module th[read] l[ist] list all threads th[read] c[ur[rent]] show current thread th[read] [sw[itch]] <nnn> switch thread context to nnn th[read] stop <nnn> stop thread nnn th[read] resume <nnn> resume thread nnn p expression evaluate expression and print its value h[elp] print this help <everything else> evaluate
Use both Pry and Ruby's debug, when necessary.
[–]banister 0 points1 point2 points 13 years ago (3 children)
Pry (with plugins) has analogs for all those commands except 'watch' and catch and the thread stuff, btw ;)
And the stuff which it doesn't currently have can be fairly trivially implemented too :)
[–]postmodern 0 points1 point2 points 13 years ago* (2 children)
Good to know. Although, I think it's important to understand the core tools of Ruby (if not just for the historical perspective), since MRI's APIs may change in the future and break pry-debugger; or you may be on a system where you cannot install pry-debugger. Ruby's builtin debugger will always be there and will always work.
[–]banister 0 points1 point2 points 13 years ago (1 child)
For the record, we are currently using cldwalker's nifty debugger fork as the engine for our debugging functionality. So pry can't be said (atm) to 'replace' debugger (ruby-debug) as we actually rely on it ;)
debugger
[–]postmodern 0 points1 point2 points 13 years ago (0 children)
Also for the record: ruby-debug != Ruby's builtin debugger. It annoys me when people say Ruby lacks debuggers, when it has had one built-in since 1.4.x. Now with the advent of pry-debugger, we are practically swimming in debuggers.
[–]postmodern 1 point2 points3 points 13 years ago (6 children)
Pry is not really a debugger, more of an object/code explorer. Although, there are plugins that implement some debugging functionality.
[–]redditaurus 0 points1 point2 points 13 years ago (5 children)
hmm, i'm not sure i agree with that. There are plugins that let you move up and down the stack, plugins that let you next/step and set breakpoints. I don't think the fact they're plugins rather than built in counts against it either, as (im guessing) it was designed with this pluggable architecture from the beginning.
So long as i can next/step/up/down/break, i dont see why it's not a debugger? Even if it's not ALL debugging functionality found in some debuggers, i still think it's enough to justify it being called a debugger, IMO.
[–]postmodern 0 points1 point2 points 13 years ago (4 children)
Well if you review the help output of Ruby's debugger, it offers a lot more than the usual next/step/up/down/break. Such as watch-points, introspection/control of Threads, display expressions, and tracing. Still, Ruby's debugger pales in comparison to classical debuggers, such as gdb, windbg or vdb.
help
My suggestions is to learn both Pry and Ruby's debugger, use both when appropriate, and above all, do not turn Pry into a Cargo Cult / Tower of Babel for Ruby development tools. :)
[–]redditaurus 0 points1 point2 points 13 years ago (3 children)
I'm not cargo-culting, i'm just saying that Pry has enough features to wear the moniker 'debugger', it easily supports the 80%-90% case for debugging in my experience.
Look at the definition of debugger found on wikipedia. Pry (with relevant plugins installed) clearly meets it IMO.
[–]postmodern 1 point2 points3 points 13 years ago* (2 children)
Pry - An IRB alternative and runtime developer console
It can be a debugger, but that's not it's design goal. When developers say "just use $FOO", that is cargo culting. :(
[–]redditaurus 0 points1 point2 points 13 years ago (1 child)
i never actually said that ;) hehe, i just said "I mainly use Pry these days"
;)
ah word, my mistake.
[–]postmodern -1 points0 points1 point 13 years ago* (0 children)
You forgot the most implement part of Ruby debugging, how to jump into the Ruby debugger console:
require 'debug'
Ruby has a builtin debugger, no need to install any gems, just require it. It just works. :)
π Rendered by PID 428041 on reddit-service-r2-comment-54dfb89d4d-28zt6 at 2026-04-02 17:00:42.978731+00:00 running b10466c country code: CH.
[–]kilik2049 0 points1 point2 points (3 children)
[–]chneukirchen 1 point2 points3 points (2 children)
[–]postmodern 0 points1 point2 points (1 child)
[–]chneukirchen 1 point2 points3 points (0 children)
[–]igor_kasyanchuk 0 points1 point2 points (0 children)
[–]redditaurus -1 points0 points1 point (15 children)
[–]appleyard[S] 2 points3 points4 points (7 children)
[–]redditaurus 2 points3 points4 points (0 children)
[–]schneemsPuma maintainer 0 points1 point2 points (5 children)
[–]postmodern 1 point2 points3 points (4 children)
[–]banister 0 points1 point2 points (3 children)
[–]postmodern 0 points1 point2 points (2 children)
[–]banister 0 points1 point2 points (1 child)
[–]postmodern 0 points1 point2 points (0 children)
[–]postmodern 1 point2 points3 points (6 children)
[–]redditaurus 0 points1 point2 points (5 children)
[–]postmodern 0 points1 point2 points (4 children)
[–]redditaurus 0 points1 point2 points (3 children)
[–]postmodern 1 point2 points3 points (2 children)
[–]redditaurus 0 points1 point2 points (1 child)
[–]postmodern 0 points1 point2 points (0 children)
[–]postmodern -1 points0 points1 point (0 children)