rubyprybyebug

Why is my pry-byebug package giving so much output when a command executes some error?


I had recently installed the gem pry-byebug, when I noticed it required at least Ruby version 2.4 in order to function. So I updated my Ruby using rvm, and then installed the gems pry and pry-byebug. Everything was working just fine. I started writing some code and setting some breakpoints with binding.pry.

But now when I am debugging, I have to deal with a huge amount of output from what ostensibly is the code base of pry-byebug, and this has made my debugging process quite more obfuscated, since I must shift through all this redundant output in order to pinpoint where my problem is.

As an example, let us say I set a binding.pry breakpoint in a part of the code where I have instantiated some objects.

casting1= {'movie_name'=> 'The Room, 'star_name'=> 'Tommy Wiseau', 'star_fee'=>20000}
casting2= {'movie_name'=> 'Come and See', 'star_name'=> 'Aleksei Kravchenko', 'star_fee'=>1000}
casting_object1= Casting.new(casting1)
casting_object2= Casting.new(casting2)

binding.pry()

Let's assume that I start looking at the objects casting_object1 and casting_object2 in order to figure out whether their methods have been properly written, and that I accidentally type in some minor error like calling an object/function that does not exist. I get this kind of output:

[1] pry(main)> casting_object1
[2] pry(main)> casting_object5

Traceback (most recent call last):
        27: from console.rb:64:in `<main>'
        26: from /Users/bob/.rvm/gems/ruby-head/gems/byebug-11.1.1/lib/byebug/context.rb:98:in `at_line'
        25: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:65:in `at_line'
        24: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:113:in `resume_pry'
        23: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:29:in `run'
        22: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:29:in `catch'
        21: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:30:in `block in run'
        20: from /Users/bob/.rvm/gems/ruby-head/gems/byebug-11.1.1/lib/byebug/helpers/eval.rb:94:in `allowing_other_threads'
        19: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:30:in `block (2 levels) in run'
        18: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:117:in `block in resume_pry'
        17: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_class.rb:200:in `start'
        16: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:13:in `start'
        15: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:38:in `start'
        14: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/input_lock.rb:77:in `with_ownership'
        13: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/input_lock.rb:59:in `__with_ownership'
        12: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:38:in `block in start'
        11: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:67:in `repl'
        10: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:67:in `loop'
         9: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:77:in `block in repl'
         8: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:272:in `eval'
         7: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:272:in `catch'
         6: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:273:in `block in eval'
         5: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:273:in `catch'
         4: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:274:in `block (2 levels) in eval'
         3: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:355:in `handle_line'
         2: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:387:in `evaluate_ruby'
         1: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:387:in `eval'
(pry):3:in `<main>': undefined local variable or method `casting' for main:Object (NameError)
Did you mean?  casting_object2
               casting_object1
        27: from console.rb:64:in `<main>'
        26: from /Users/bob/.rvm/gems/ruby-head/gems/byebug-11.1.1/lib/byebug/context.rb:98:in `at_line'
        25: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:65:in `at_line'
        24: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:113:in `resume_pry'
        23: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:29:in `run'
        22: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:29:in `catch'
        21: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:30:in `block in run'
        20: from /Users/bob/.rvm/gems/ruby-head/gems/byebug-11.1.1/lib/byebug/helpers/eval.rb:94:in `allowing_other_threads'
        19: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:30:in `block (2 levels) in run'
        18: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:117:in `block in resume_pry'
        17: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_class.rb:200:in `start'
        16: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:13:in `start'
        15: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:38:in `start'
        14: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/input_lock.rb:77:in `with_ownership'
        13: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/input_lock.rb:59:in `__with_ownership'
        12: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:38:in `block in start'
        11: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:67:in `repl'
        10: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:67:in `loop'
         9: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/repl.rb:77:in `block in repl'
         8: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:272:in `eval'
         7: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:272:in `catch'
         6: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:273:in `block in eval'
         5: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:273:in `catch'
         4: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:274:in `block (2 levels) in eval'
         3: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:349:in `handle_line'
         2: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_instance.rb:356:in `rescue in handle_line'
         1: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/exceptions.rb:16:in `==='
/Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/exceptions.rb:28:in `===': undefined method `>' for nil:NilClass (NoMethodError)
        12: from console.rb:64:in `<main>'
        11: from /Users/bob/.rvm/gems/ruby-head/gems/byebug-11.1.1/lib/byebug/context.rb:98:in `at_line'
        10: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:65:in `at_line'
         9: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:113:in `resume_pry'
         8: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:29:in `run'
         7: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:29:in `catch'
         6: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:30:in `block in run'
         5: from /Users/bob/.rvm/gems/ruby-head/gems/byebug-11.1.1/lib/byebug/helpers/eval.rb:94:in `allowing_other_threads'
         4: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:30:in `block (2 levels) in run'
         3: from /Users/bob/.rvm/gems/ruby-head/gems/pry-byebug-3.8.0/lib/byebug/processors/pry_processor.rb:117:in `block in resume_pry'
         2: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_class.rb:169:in `start'
         1: from /Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/pry_class.rb:201:in `rescue in start'
/Users/bob/.rvm/gems/ruby-head/gems/pry-0.12.2/lib/pry/exceptions.rb:28:in `===': undefined method `>' for nil:NilClass (NoMethodError)

No matter what kind of error is evoked, I consistently get this kind of output that appears to be referring to code in the code base of the pry or pry-byebug gem. While this is not a major problem (since I can still set breakpoints and manipulate objects in pry), there is so much superfluous output that the process of pinpointing bugs becomes not particularly easy or clear-cut, especially in the terminal setting. I have tried to amend this problem myself by uninstalling and reinstalling the gems pry and pry-byebug, and have also tried to install previous versions of pry and pry-byebug in order for it to work. I have tried to googling this issue, but I sadly am not familiar enough with the terminology in order to pinpoint what the matter actually is.

Ever since I updated my Ruby with rvm, this problem has been occurring. I would prefer not to go back to an older version of Ruby since some of the gems I use in my code require the latest version. Can anybody give me any feedback to explain why this is happening, and possibly, how I can solve it? I am using macOS Mojave v10.14.6, and utilizing Ruby v2.7.0-preview1

UPDATE

So I went to the github repository of pry-byebug and I found that some other users encountered the same problem as me.

https://github.com/deivid-rodriguez/pry-byebug/issues/138

https://github.com/deivid-rodriguez/pry-byebug/issues/110

Sadly, both these issues remain unresolved, but one user did say there was a way to "monkey patch" the problem using the function print_traceback. After locating the print_traceback function in the where.rb file of the bye-bug gem, I tried to implement this monkey patch. Sadly it did not work for me.


Solution

  • so I recently just used rvm to download and set my default version of Ruby to 2.6.5. The verbose output has now ceased entirely.