SlideShare a Scribd company logo
Debugging with pry
❤
Murilo Capanema - 2015
Who Am I?
GitHub: mcapanema
BankFacil (We are Hiring!)
Murilo Capanema - 2015
What is pry ?
Pry is a powerful alternative to the standard IRB shell
for Ruby.
Murilo Capanema - 2015
Why pry ?
Features:
4 syntax highlighting;
4 flexible plugin architecture;
4 runtime invocation and source
and documentation browsing;
Murilo Capanema - 2015
Why not to use pry ?
Murilo Capanema - 2015
Murilo Capanema - 2015
What really is pry ?
One line of ruby:
def repl
loop{ puts eval $stdin.readline}
end
Murilo Capanema - 2015
A little bit of REPL
Read
Eval
Print
Loop
Murilo Capanema - 2015
A little bit of REPL
REPL with Tests
4 REPL first !;
4 Record what the code should do ";
4 Write a code that works first time #;
Murilo Capanema - 2015
Why REPL ?
REPL or Debugger Driven Development helps you to reach a code that works pretty quickly
Murilo Capanema - 2015
Backing to pry
require 'pry'
binding.pry
Murilo Capanema - 2015
Pry and his friends
4 pry-stack-explorer;
4 pry-debugger;
4 pry-rescue;
4 pry-doc;
4 pry-git;
4 help
Murilo Capanema - 2015
Pry magics
ls
[1] pry(main)> ls
self.methods: inspect to_s
locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
ls
[1] pry(main)> ls Kernel
constants: RUBYGEMS_ACTIVATION_MONITOR
Kernel.methods:
Array Rational abort block_given? exit global_variables open putc require sprintf trace_var
Complex String ap caller exit! iterator? p puts require_relative srand trap
Float __callee__ at_exit caller_locations fail lambda pp raise select syscall untrace_var
Hash __dir__ autoload catch fork load print rand set_trace_func system warn
Integer __method__ autoload? eval format local_variables printf readline sleep test
Pathname ` binding exec gets loop proc readlines spawn throw
Kernel#methods:
!~ clone frozen? kind_of? public_methods tainted?
<=> debugger hash method public_send tap
=== define_singleton_method inspect methods remove_instance_variable to_enum
=~ display instance_of? nil? respond_to? to_s
ai dup instance_variable_defined? object_id send trust
awesome_inspect enum_for instance_variable_get pretty_inspect singleton_class untaint
awesome_print eql? instance_variable_set private_methods singleton_method untrust
byebug extend instance_variables protected_methods singleton_methods untrusted?
class freeze is_a? public_method taint
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
$ - show-source
[1] pry(main)> $ Kernel#puts
From: io.c (C Method):
Owner: Kernel
Visibility: private
Number of lines: 8
static VALUE
rb_f_puts(argc, argv)
int argc;
VALUE *argv;
{
rb_io_puts(argc, argv, rb_stdout);
return Qnil;
}
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
$ - show-source
[1] pry(main)> $ Hash
From: /home/vagrant/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/pp.rb @ line 369:
Class name: Hash
Number of lines: 9
class Hash # :nodoc:
def pretty_print(q) # :nodoc:
q.pp_hash self
end
def pretty_print_cycle(q) # :nodoc:
q.text(empty? ? '{}' : '{...}')
end
end
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
? - show-doc
[1] pry(main)> ? Object
From: /home/vagrant/.rvm/gems/ruby-2.1.3/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/object.rb @ line 1:
Class name: Object
Number of monkeypatches: 6. Use the `-a` option to display all available monkeypatches
Number of lines: 5
...
...
...
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
break
[1] pry(main)> break method_name
Breakpoint 1: /path/to/file.rb @ line 1 (Enabled):
...
...
...
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
try-again
[1] pry(main)> try-again
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
step/next
[1] pry(main)> step
[2] pry(main)> next
Murilo Capanema - 2015
Pry magics
play
[1] pry(main)> play -l 1
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
edit [OPTIONS]
4 -e Open editor on last exception raised
4 -m Open editor on a given method
4 -c Open editor on current method
[1] pry(main)> edit -m method_name
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
up
[1] pry(main)> up
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
down
[1] pry(main)> down
[2] pry(main)>
Murilo Capanema - 2015
Pry magics
@ - whereami
[1] pry(Kernel):1> cd Kernel#puts
[2] pry(Kernel):2> @
Inside Kernel.
[3] pry(Kernel):2>
Murilo Capanema - 2015
Debugging
4 Reproduce locally;
4 Find the problem;
4 Fix it;
Murilo Capanema - 2015
More pry magics
wtf - _ex_.backtrace
[1] pry(Kernel):1> wtf?
...
...
...
[2] pry(Kernel):2>
Murilo Capanema - 2015
Further Reading
https://www.youtube.com/watch?v=D9j_Mf91M0I
https://www.youtube.com/watch?v=4hfMUP5iTq8
https://github.com/nixme/jazz_hands
http://pryrepl.org/
Murilo Capanema - 2015
Fin
GitHub: mcapanema
Seriously We are Hiring!
Murilo Capanema - 2015

More Related Content

PDF
Make Your Own Perl with Moops
PDF
C++ for Java Developers (JavaZone Academy 2018)
PDF
The Perl API for the Mortally Terrified (beta)
PDF
Metasepi team meeting #20: Start! ATS programming on MCU
PDF
Hands-on VeriFast with STM32 microcontroller
PDF
Catch a spider monkey
ODP
What's new in Perl 5.10?
PDF
Metasepi team meeting #19: ATS application on Arduino
Make Your Own Perl with Moops
C++ for Java Developers (JavaZone Academy 2018)
The Perl API for the Mortally Terrified (beta)
Metasepi team meeting #20: Start! ATS programming on MCU
Hands-on VeriFast with STM32 microcontroller
Catch a spider monkey
What's new in Perl 5.10?
Metasepi team meeting #19: ATS application on Arduino

What's hot (18)

PDF
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...
PDF
Metasepi team meeting #14: ATS programming on MCU
PDF
Development Principles & Philosophy
PPTX
Php Extensions for Dummies
PDF
Metasepi team meeting #16: Safety on ATS language + MCU
PDF
Real-time OS system state captured by ATS language
PDF
Start! ATS programming
PDF
Embedded application designed by ATS language
PPTX
Fasterflect
PDF
Better rspec 進擊的 RSpec
PDF
March2004-CPerlRun
PDF
Diving into HHVM Extensions (php[tek] 2016)
PDF
ATS Programming Tutorial
PDF
Create your own PHP extension, step by step - phpDay 2012 Verona
PDF
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
PDF
Implementing pattern-matching in JavaScript (short version)
PDF
Rust & Gamedev
PDF
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...
Metasepi team meeting #14: ATS programming on MCU
Development Principles & Philosophy
Php Extensions for Dummies
Metasepi team meeting #16: Safety on ATS language + MCU
Real-time OS system state captured by ATS language
Start! ATS programming
Embedded application designed by ATS language
Fasterflect
Better rspec 進擊的 RSpec
March2004-CPerlRun
Diving into HHVM Extensions (php[tek] 2016)
ATS Programming Tutorial
Create your own PHP extension, step by step - phpDay 2012 Verona
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
Implementing pattern-matching in JavaScript (short version)
Rust & Gamedev
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018
Ad

Viewers also liked (15)

PDF
Jurassic JavaScript Park - Rodando Offline até na ilha Nublar!
PDF
How To Get Organized
PDF
A arte de ser Mensch
PPTX
Rails in the bowels
PDF
Positive reinforcement and statistics
PDF
O que o seu texto diz sobre você
PDF
O paradoxo da escolha
PDF
Modern sql
PDF
Sublime
PDF
Text mining Pre-processing
PDF
OOCSS and SMACSS
PDF
An introduction to MySQL
PPTX
Como melhorar sua comunicação com sua equipe, sua mãe e seu chefe
PPTX
Pig - Analyzing data sets
PDF
Melanoma: how to detect skin cancer
Jurassic JavaScript Park - Rodando Offline até na ilha Nublar!
How To Get Organized
A arte de ser Mensch
Rails in the bowels
Positive reinforcement and statistics
O que o seu texto diz sobre você
O paradoxo da escolha
Modern sql
Sublime
Text mining Pre-processing
OOCSS and SMACSS
An introduction to MySQL
Como melhorar sua comunicação com sua equipe, sua mãe e seu chefe
Pig - Analyzing data sets
Melanoma: how to detect skin cancer
Ad

Similar to Debugging with pry (20)

PDF
Exploring Code with Pry!
PDF
Killing Bugs with Pry
PDF
Some Pry Features
PPTX
Debugging Ruby (with Pry)
PDF
Rubyslava debugging with_pry
PPTX
REPL-driven development with pry
PDF
Ruby Presentation
PDF
Pry at the Ruby Drink-up of Sophia, February 2012
PDF
Ruby — An introduction
PDF
Workin On The Rails Road
PDF
JRuby 9000 - Optimizing Above the JVM
PPTX
Day 1 - Intro to Ruby
PPT
name name2 n2.ppt
PPT
name name2 n
PPT
name name2 n2
PPT
name name2 n
PPT
ppt18
PPT
ppt9
PPT
ppt7
PPT
ppt30
Exploring Code with Pry!
Killing Bugs with Pry
Some Pry Features
Debugging Ruby (with Pry)
Rubyslava debugging with_pry
REPL-driven development with pry
Ruby Presentation
Pry at the Ruby Drink-up of Sophia, February 2012
Ruby — An introduction
Workin On The Rails Road
JRuby 9000 - Optimizing Above the JVM
Day 1 - Intro to Ruby
name name2 n2.ppt
name name2 n
name name2 n2
name name2 n
ppt18
ppt9
ppt7
ppt30

More from Creditas (12)

PPTX
Hanami & Domain-Driven Design
PDF
Application layer
PDF
Hanami with a modern touch
PDF
Rails Girls - RubyConfBR 2015
PPTX
GTD - Getting Things Done
PDF
Neo4 j
PDF
Learning how to learn
PDF
Solid - OOD Principles
PPTX
Sistemas de recomendação em ruby
PDF
Do MONOLÍTICO à arquitetura distribuída
PDF
Minitest
PDF
Deploy Heroku
Hanami & Domain-Driven Design
Application layer
Hanami with a modern touch
Rails Girls - RubyConfBR 2015
GTD - Getting Things Done
Neo4 j
Learning how to learn
Solid - OOD Principles
Sistemas de recomendação em ruby
Do MONOLÍTICO à arquitetura distribuída
Minitest
Deploy Heroku

Recently uploaded (20)

PPTX
history of c programming in notes for students .pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
System and Network Administration Chapter 2
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
System and Network Administraation Chapter 3
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
AI in Product Development-omnex systems
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
medical staffing services at VALiNTRY
PPTX
Introduction to Artificial Intelligence
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
history of c programming in notes for students .pptx
Softaken Excel to vCard Converter Software.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
How Creative Agencies Leverage Project Management Software.pdf
System and Network Administration Chapter 2
Navsoft: AI-Powered Business Solutions & Custom Software Development
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
System and Network Administraation Chapter 3
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Understanding Forklifts - TECH EHS Solution
AI in Product Development-omnex systems
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
medical staffing services at VALiNTRY
Introduction to Artificial Intelligence
Upgrade and Innovation Strategies for SAP ERP Customers
PTS Company Brochure 2025 (1).pdf.......
VVF-Customer-Presentation2025-Ver1.9.pptx

Debugging with pry

  • 2. Who Am I? GitHub: mcapanema BankFacil (We are Hiring!) Murilo Capanema - 2015
  • 3. What is pry ? Pry is a powerful alternative to the standard IRB shell for Ruby. Murilo Capanema - 2015
  • 4. Why pry ? Features: 4 syntax highlighting; 4 flexible plugin architecture; 4 runtime invocation and source and documentation browsing; Murilo Capanema - 2015
  • 5. Why not to use pry ? Murilo Capanema - 2015
  • 7. What really is pry ? One line of ruby: def repl loop{ puts eval $stdin.readline} end Murilo Capanema - 2015
  • 8. A little bit of REPL Read Eval Print Loop Murilo Capanema - 2015
  • 9. A little bit of REPL REPL with Tests 4 REPL first !; 4 Record what the code should do "; 4 Write a code that works first time #; Murilo Capanema - 2015
  • 10. Why REPL ? REPL or Debugger Driven Development helps you to reach a code that works pretty quickly Murilo Capanema - 2015
  • 11. Backing to pry require 'pry' binding.pry Murilo Capanema - 2015
  • 12. Pry and his friends 4 pry-stack-explorer; 4 pry-debugger; 4 pry-rescue; 4 pry-doc; 4 pry-git; 4 help Murilo Capanema - 2015
  • 13. Pry magics ls [1] pry(main)> ls self.methods: inspect to_s locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_ [2] pry(main)> Murilo Capanema - 2015
  • 14. Pry magics ls [1] pry(main)> ls Kernel constants: RUBYGEMS_ACTIVATION_MONITOR Kernel.methods: Array Rational abort block_given? exit global_variables open putc require sprintf trace_var Complex String ap caller exit! iterator? p puts require_relative srand trap Float __callee__ at_exit caller_locations fail lambda pp raise select syscall untrace_var Hash __dir__ autoload catch fork load print rand set_trace_func system warn Integer __method__ autoload? eval format local_variables printf readline sleep test Pathname ` binding exec gets loop proc readlines spawn throw Kernel#methods: !~ clone frozen? kind_of? public_methods tainted? <=> debugger hash method public_send tap === define_singleton_method inspect methods remove_instance_variable to_enum =~ display instance_of? nil? respond_to? to_s ai dup instance_variable_defined? object_id send trust awesome_inspect enum_for instance_variable_get pretty_inspect singleton_class untaint awesome_print eql? instance_variable_set private_methods singleton_method untrust byebug extend instance_variables protected_methods singleton_methods untrusted? class freeze is_a? public_method taint [2] pry(main)> Murilo Capanema - 2015
  • 15. Pry magics $ - show-source [1] pry(main)> $ Kernel#puts From: io.c (C Method): Owner: Kernel Visibility: private Number of lines: 8 static VALUE rb_f_puts(argc, argv) int argc; VALUE *argv; { rb_io_puts(argc, argv, rb_stdout); return Qnil; } [2] pry(main)> Murilo Capanema - 2015
  • 16. Pry magics $ - show-source [1] pry(main)> $ Hash From: /home/vagrant/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/pp.rb @ line 369: Class name: Hash Number of lines: 9 class Hash # :nodoc: def pretty_print(q) # :nodoc: q.pp_hash self end def pretty_print_cycle(q) # :nodoc: q.text(empty? ? '{}' : '{...}') end end [2] pry(main)> Murilo Capanema - 2015
  • 17. Pry magics ? - show-doc [1] pry(main)> ? Object From: /home/vagrant/.rvm/gems/ruby-2.1.3/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/object.rb @ line 1: Class name: Object Number of monkeypatches: 6. Use the `-a` option to display all available monkeypatches Number of lines: 5 ... ... ... [2] pry(main)> Murilo Capanema - 2015
  • 18. Pry magics break [1] pry(main)> break method_name Breakpoint 1: /path/to/file.rb @ line 1 (Enabled): ... ... ... [2] pry(main)> Murilo Capanema - 2015
  • 19. Pry magics try-again [1] pry(main)> try-again [2] pry(main)> Murilo Capanema - 2015
  • 20. Pry magics step/next [1] pry(main)> step [2] pry(main)> next Murilo Capanema - 2015
  • 21. Pry magics play [1] pry(main)> play -l 1 [2] pry(main)> Murilo Capanema - 2015
  • 22. Pry magics edit [OPTIONS] 4 -e Open editor on last exception raised 4 -m Open editor on a given method 4 -c Open editor on current method [1] pry(main)> edit -m method_name [2] pry(main)> Murilo Capanema - 2015
  • 23. Pry magics up [1] pry(main)> up [2] pry(main)> Murilo Capanema - 2015
  • 24. Pry magics down [1] pry(main)> down [2] pry(main)> Murilo Capanema - 2015
  • 25. Pry magics @ - whereami [1] pry(Kernel):1> cd Kernel#puts [2] pry(Kernel):2> @ Inside Kernel. [3] pry(Kernel):2> Murilo Capanema - 2015
  • 26. Debugging 4 Reproduce locally; 4 Find the problem; 4 Fix it; Murilo Capanema - 2015
  • 27. More pry magics wtf - _ex_.backtrace [1] pry(Kernel):1> wtf? ... ... ... [2] pry(Kernel):2> Murilo Capanema - 2015
  • 29. Fin GitHub: mcapanema Seriously We are Hiring! Murilo Capanema - 2015