Questions tagged [pry]

Pry is an alternative to the standard Ruby interpreter, IRB.

Pry is an REPL (Read Eval Print Loop) interpreter, allowing to access the source code and the documentation, edit methods and execute shell commands.

http://pry.github.com/

459 questions
240
votes
10 answers

How do I step out of a loop with Ruby Pry?

I'm using Pry with my Rails application. I set binding.pry inside a loop in my model to try and debug a problem. For example: (1..100).each do |i| binding.pry puts i end When I type quit, it goes to the next iteration and stops again. Is there…
Ryan
  • 9,340
  • 5
  • 39
  • 42
129
votes
5 answers

Pry: show me the stack

Using Pry in Rails, when I hit a breakpoint in the code binding.pry I want to know how I got here, who called me, who called them, etc. But oddly I don't see that command. Does anyone know?
pitosalas
  • 10,286
  • 12
  • 72
  • 120
56
votes
6 answers

How to debug a rails app in docker with pry?

I have a rails app running in a docker container in development environment. When I try to debug it with placing binding.pry somewhere in the code and attaching to the container I can see the pry prompt in the output but it doesn't pause on it and I…
fey
  • 1,289
  • 1
  • 10
  • 20
50
votes
5 answers

tree command on osx bash

I'm following a screen cast on a ruby gem called pry. At 8:10, the .tree command is used, which I believe is a Unix command. It does not appear to be working on my system: [24] pry(main)> .tree \Error: there was a problem executing system command:…
JZ.
  • 21,147
  • 32
  • 115
  • 192
49
votes
5 answers

Is there the equivalent of next in Pry?

I don't see a way of just going to the next line when using pry as a debugger. All I can find is to edit the method and move binding.pry to the next line. Is there such a feature? 22: def scan path 23: @last_line_had_text, @files_read,…
Jeremy Smith
  • 14,727
  • 19
  • 67
  • 114
49
votes
5 answers

Can't escape from eval with next using Pry-rails

Hi I've installed Pry to do some awesome debugging and had it working before but when I step into the code with 'next' I get the following error: SyntaxError: (eval):2: Can't escape from eval with next Code being used: def create binding.pry …
Shaun Frost Duke Jackson
  • 1,256
  • 1
  • 10
  • 22
41
votes
9 answers

pry gem how to reload?

I am using the Pry gem in my Rails console, but the pry flavored rails-console seems to have lost the reload! method for reloading models and stuff. Here's how I start the pry console c:\rails\app> pry -r ./config/environment Thank You
Nik So
  • 16,683
  • 21
  • 74
  • 108
36
votes
3 answers

How to move to the next line in binding.pry ?

In byebug we can move to next line by typing 'n', similarly is there anyway to move to the next line in 'pry' ? I have gone through there documentation but nothing's works out.
vikas95prasad
  • 1,234
  • 1
  • 12
  • 37
35
votes
4 answers

How to use Pry with Sinatra?

I am writing my first Sinatra application and would like to use Pry to inspect/debug some things going on in the application. I haven't used Pry before either, but I would like to try it out. How would I get started using Pry with my Sinatra…
Andrew
  • 227,796
  • 193
  • 515
  • 708
30
votes
4 answers

`binding.pry` for javascript console?

In Ruby, I can type binding.pry anywhere in my code and at that point of execution my console will enter a REPL where I have access to all local variables, can make changes, and execute any arbitrary code. Example: # foo.rb require 'pry' n =…
cgenco
  • 3,370
  • 2
  • 31
  • 36
28
votes
4 answers

How to examine rspec variables with pry debugger

I've seen some SO posts explaining how to use pry to step into rspec tests and been able to do this. Once I reach the breakpoint though, I'm struggling to display any useful information. For this code below, I'd like to examine the response object…
PropertyWebBuilder
  • 1,286
  • 2
  • 12
  • 18
28
votes
7 answers

Start ruby debugger if rspec test fails

Often, when a test fails, I spend quite sometime trying to figure out the what caused it to fail. It'd be useful if RSpec could kick off a Ruby debugger when the test fails, so that I can inspect the local variables immediately to drill down on the…
Vighnesh
  • 708
  • 8
  • 25
28
votes
2 answers

Guard-rails not providing REPL for binding.pry

I'm using guard-rails to run my rails server, my problem is I can't access the REPL when I add binding.pry I just get From: /home/martinr/code/app/controllers/tools_controller.rb @ line 2 ToolsController#index: 2: def index => 3: …
Martinffx
  • 2,426
  • 4
  • 33
  • 60
26
votes
1 answer

Pry Error: Cannot find local context. Did you use `binding.pry`?

Why am I getting this pry error? [36] pry(main)> s = "pry" Error: Cannot find local context. Did you use `binding.pry`? It works fine in this screencast http://pryrepl.org/
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
22
votes
2 answers

Puma Rails 5 binding.pry only available for 60 seconds before timeout

Puma times out my request when I'm using binding.pry. In my controller def new require 'pry' binding.pry end I then make a request that hits the controller and enter the pry session. After 60 seconds Puma? times out my request, restarts a…
thedanotto
  • 6,895
  • 5
  • 45
  • 43
1
2 3
30 31