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
390
2
Share
Efficient debugging with Pry
A short talk summarizing how to use Pry to save yourself time when debugging.
Conrad Irwin
October 02, 2012
More Decks by Conrad Irwin
See All by Conrad Irwin
Go for Rubyists
conradirwin
2
300
REPL Driven Development with Pry!
conradirwin
5
1.6k
MongoDB — confessions of a PostgreSQL lover
conradirwin
3
4k
Debugging with Pry
conradirwin
0
140
Debuggable Code
conradirwin
1
280
Pry — the good parts!
conradirwin
25
1.7k
Other Decks in Programming
See All in Programming
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
260
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
330
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
890
forteeの改修から振り返るPHPerKaigi 2026
muno92
PRO
3
280
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
550
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
130
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.5k
ハンズオンで学ぶクラウドネイティブ
tatsukiminami
0
130
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
140
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
1
180
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
240
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
180
Featured
See All Featured
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
53k
Writing Fast Ruby
sferik
630
63k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.5k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
120
Rails Girls Zürich Keynote
gr2m
96
14k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Designing for humans not robots
tammielis
254
26k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
470
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