Using pry-byebug and not happy with commands behavior? We recommend this project instead
pry-moves
An execution control add-on for Pry.
- Install:
gem 'pry-moves' - For non-rails (without auto-require), add to your script:
require 'pry-moves'
Commands:
n- next line in current frame, including block lines (moving to next line goes as naturally expected)s- step into function executions func_name- step into first method called by namefunc_name
f- finish execution of current frame (block or method) and stop at next line on higher levelc- continuebt- show latest 5 lines from backtracebt 10- latest 10 linesbt all- full backtracebt >foo- write backtrace to filelog/backtrace_foo.log
up/down/top/bottom- move over call stackup +- move up, including vapid frames (block callers, hidden frames)up pattern- move up till first frame which method name or file position in formatfolder/script.rb:12matches regexp pattern
debug some_method(param, param2)- callsome_method(param, param2)and interactively step into it!- exit
Examples
To use, invoke pry normally:
def some_method
binding.pry # Execution will stop here.
puts 'Hello, World!' # Run 'step' or 'next' in the console to move here.
end
Advanced example

Demo class source here
Backtrace and call stack
You can explicitly hide frames from backtrace and call stack by defining hide_from_stack variable:
def insignificant_method
hide_from_stack = true
something_insignificant
yield
end
Configuration
Here is default configuration, you can override it:
PryMoves::Backtrace::lines_count = 5
PryMoves::Backtrace::filter =
/(\/gems\/|\/rubygems\/|\/bin\/|\/lib\/ruby\/|\/pry-moves\/)/
Threads, helpers
pry-moves can't stop other threads on binding.pry, so they will continue to run.
This makes pry-moves not always suitable for debugging of multi-thread projects.
Though you can pause other threads with helper which will suspend execution on current line,
until ongoing debug session will be finished with continue:
PryMoves.synchronize_threads
For example, you can put it into function which periodically reports status of thread (if you have such)
Other helpers:
PryMoves.open?- if pry input dialog active. Can be used to suppress output from ongoing parallel threads
pry-remote
Rudimentary support for pry-remote (>= 0.1.1) is also included.
Ensure pry-remote is loaded or required before pry-moves. For example, in a
Gemfile:
gem 'pry'
gem 'pry-remote'
gem 'pry-moves'
Performance
Please note that debugging functionality is implemented through
set_trace_func, which imposes certain performance penalty.
Contributors
- Gopal Patel (@nixme)
- John Mair (@banister)
- Conrad Irwin (@ConradIrwin)
- Benjamin R. Haskell (@benizi)
- Jason R. Clark (@jasonrclark)
- Ivo Anjo (@ivoanjo)
Patches and bug reports are welcome. Just send a pull request or file an issue. Project changelog.
Acknowledgments
- Gopal Patel's pry-nav
- John Mair's pry-stack_explorer
- Ruby stdlib's debug.rb
- @Mon-Ouie's pry_debug