Binding.pry not showing the stopping point in console after ruby 3 upgrade

794 Views Asked by At

I am new to ruby, we have a ROR microservice(rails version 6.1) , recently i updated the ruby version on the service from 2.7 to 3.0 , after this since there were failures and i wanted to debug it, so i added binding.pry , when the binding.pry is encountered the flow stops but its doesnt show the exact line where the binding.pry has stopped in the console and no matter what command i give it conitnues the flow .

screenshot of console when binding.pry is encountered in code

Below are the relevant gems versions from gemfile


  ruby '>=3.0'
  gem 'rails', '~> 6.1'
  gem 'pry', '~> 0.10.3'
  gem 'pry-byebug', '~> 3.4'
  gem 'pry-rails', '~> 0.3'
  gem 'rdoc', '>= 6.3.1'
gem 'webrick', '~> 1.8'

I want to get the binding.pry to work properly, how it used to with older ruby 2.7 version, so that i could debug the actual issues that the service is facing after 3.0 upgrade Please suggest me guys.

EDIT 1: I want the output on the console once the binding.pry is encountered to be something like this:

    2: def example()
    3:   str="this is an example string"
    4:   arr= ["abc", "xyz" , "geh"]
 => 5:   binding.pry
    6:   arr[0]
    7:
    8: end
2

There are 2 best solutions below

0
On

Pry does not support Ruby 3 until version 0.14.0, so you need to update pry to >= 0.14

2
On

I've often run into the issue where, if I put a binding.pry to test an endpoint (whether using Postman or localhost), and the request is either sent multiple times due to redirects or the entity sending the request sends it multiple times, the console won't respond. It'll stop at the break point but I can't type anything.

My fix

What I usually do to fix this is send one request then quickly stop the request (canceling the Postman request). Then I'll go into the console and try to type something, if I can't, I'll type exit, try to type something again, type exit etc. until I can type in the console. The idea is I'm trying to get to the last request that was sent.