Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Efficient debugging with Pry
Search
Conrad Irwin
October 02, 2012
Programming
2
390
Efficient debugging with Pry
A short talk summarizing how to use Pry to save yourself time when debugging.
Conrad Irwin
October 02, 2012
Tweet
Share
More Decks by Conrad Irwin
See All by Conrad Irwin
Go for Rubyists
conradirwin
2
290
REPL Driven Development with Pry!
conradirwin
5
1.6k
MongoDB — confessions of a PostgreSQL lover
conradirwin
3
3.9k
Debugging with Pry
conradirwin
0
140
Debuggable Code
conradirwin
1
270
Pry — the good parts!
conradirwin
25
1.7k
Other Decks in Programming
See All in Programming
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
120
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
230
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
150
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
1.1k
AI 開発合宿を通して得た学び
niftycorp
PRO
0
140
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
270
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
6
1.8k
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
210
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
440
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
1k
AHC061解説
shun_pi
0
390
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
220
Featured
See All Featured
Mind Mapping
helmedeiros
PRO
1
120
Design in an AI World
tapps
0
170
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
250
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
640
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
120
Measuring & Analyzing Core Web Vitals
bluesmoon
9
790
Documentation Writing (for coders)
carmenintech
77
5.3k
sira's awesome portfolio website redesign presentation
elsirapls
0
190
Everyday Curiosity
cassininazir
0
160
Transcript
None
Debugging l Figure out why the code is broken l
Fix it l Repeat.
puts l Most common debugging tool l Very easy to
use l Gather information one chunk at a time
binding.pry l Opens pry at that line in your code
l `gem install pry` l Gather as much information as you need l Test theories immediately
pry-rescue l Automatic binding.pry on unhandled exceptions l `gem install
pry-rescue` l Reduces feedback cycle times
NoMethodError l Most common exception in ruby code? l Caused
by: - Typos - Forgetting the right method name - Using the wrong object
ls -‐-‐grep l Finds the correct method l No
need to google l Doesn't rely on gems having docs ;)
[1] pry(main)> ls Base64 -‐-‐grep encode Base64.methods:
encode64 strict_encode64 urlsafe_encode64 [2] pry(main)>
ls -‐-‐grep l Finds the correct method l No
need to google l Doesn't rely on gems having docs ;)
edit -‐-‐ex l Opens your text editor l Jumps
to the exception l Reloads the code when you're done
From: /0/ruby/pry/example.rb @ line 3: 3:
def base64ify(email) => 4: Base64.encode(email) 5: end NoMethodError: undefined method `encode' for Base64:Module' [1] pry(main)>
From: /0/ruby/pry/example.rb @ line 3: 3:
def base64ify(email) => 4: Base64.encode(email) 5: end NoMethodError: undefined method `encode' for Base64:Module' [1] pry(main)> edit -‐-‐ex
None
[1] pry(main)> edit -‐-‐ex 3: def
base64ify(email) => 4: Base64.encode64(email) 5: end [2] pry(main)> base64ify("hello world") "aGVsbG8gd29ybGQ=\n"
up and down l Moves pry up and down the
call stack l Figure out why you have the wrong object l Discover why a gem doesn't work l `gem install pry-stack_explorer`
From: /0/ruby/pry/example2.rb @ line 2: 2:
def make_safe(text) => 3: text.gsub(/[^a-‐z]/i, '-‐') 4: end NoMethodError: undefined method `gsub' for nil:NilClass' [1] pry(main)>
[1] pry(main)> up From: /0/ruby/pry/example2.rb @ line 6:
2: def safe_title(post) => 3: make_safe(post[:title]) 4: end [2] pry(main)> post {"title" => "Hello Pry"}
up and down l Moves pry up and down the
call stack l Figure out why you have the wrong object l Discover why a gem doesn't work l `gem install pry-stack_explorer`
$ and ? l show-source and show-doc l Instant documentation
when you need it l No need to `cd` into gem directories.
[1] pry(main)> $ safe_title 2: def
safe_title(post) 3: make_safe(post[:title]) 4: end [2] pry(main)>
[2] pry(main)> ? safe_title Convert the title of the
blog into a string suitable for use in URLs. param [Hash] post return [String] [3] pry(main)>
In conclusion l Debugging requires gathering information l Get into
a `binding.pry` habit l Explore pry's extra features - gem install pry-full - Type `help` inside pry
<EOF> l @ConradIrwin (github, twitter, gmail, etc.) l http://pryrepl.org/ l
irc://freenode.net/#pry