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
380
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
280
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
260
Pry — the good parts!
conradirwin
25
1.6k
Other Decks in Programming
See All in Programming
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
8
3.4k
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
130
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
3.2k
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
4.4k
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
130
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
460
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
520
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.5k
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
420
AI時代を生き抜く 新卒エンジニアの生きる道
coconala_engineer
1
470
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
430
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
140
Featured
See All Featured
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
115
95k
Practical Orchestrator
shlominoach
190
11k
Building Adaptive Systems
keathley
44
2.9k
Everyday Curiosity
cassininazir
0
110
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
260
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
WCS-LA-2024
lcolladotor
0
390
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
860
sira's awesome portfolio website redesign presentation
elsirapls
0
92
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
0
320
Scaling GitHub
holman
464
140k
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