Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newest version of Pry breaks pry-byebug #343

Closed
thomaswuensche opened this issue Jan 16, 2021 · 15 comments · Fixed by #386
Closed

Newest version of Pry breaks pry-byebug #343

thomaswuensche opened this issue Jan 16, 2021 · 15 comments · Fixed by #386

Comments

@thomaswuensche
Copy link

The Pull Request pry/pry#2119 from November changed the way plugins are loaded in Pry: they're no longer autoloaded and need to be required in .pryrc.

However, this does not work for me with pry-byebug.

Steps to reproduce:

  • clone 'pry' and 'pry-byebug'
  • build and install gems
  • add require 'pry-byebug' to .pryrc
  • run a ruby test file with require 'pry'; binding.pry included
  • type next into Pry

Expected behaviour:
Pry executes the next line.

Observed behaviour:
Pry crashes. Stacktrace:

[1] pry(main)> next
UncaughtThrowError: uncaught throw :breakout_nav
from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-byebug-3.9.0/lib/pry-byebug/helpers/navigation.rb:15:in `throw'
Traceback (most recent call last):
	12: from test.rb:3:in `<main>'
	11: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/core_extensions.rb:45:in `pry'
	10: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_class.rb:188:in `start'
	 9: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:15:in `start'
	 8: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:38:in `start'
	 7: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/input_lock.rb:78:in `with_ownership'
	 6: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/input_lock.rb:61:in `__with_ownership'
	 5: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:38:in `block in start'
	 4: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:67:in `repl'
	 3: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:67:in `loop'
	 2: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:68:in `block in repl'
	 1: from /Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:95:in `read'
/Users/thomas/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:454:in `select_prompt': private method `eval' called for nil:NilClass (NoMethodError)

Investigation:
I believe this is the case because pry-byebug needs to be required before Pry.start is executed so that

alias start start_with_pry_byebug

applies. This was previously achieved because prior to executing Pry.start and actually loading the plugins, Pry would load the cli options through Pry::CLI.add_plugin_options. Since lib/pry-byebug/cli.rb loaded everything, this worked.

This has now changed because you need to require pry-byebug in your .pryrc and Pry.load_rc_files is executed after Pry.start.

As a hacky fix, Pry.load_rc_files can be added to pry/lib/pry.rb. This will load .pryrc and therefore require pry-byebug before Pry is started.

Questions:

  • @mvz mentioned in his PR that he successfully tested the new plugin loading with pry-byebug. Is this an error on my side, am i missing sth here?
  • Can this be fixed by changing pry-byebug or does this actually need to be adressed in Pry's code?
@mvz
Copy link
Contributor

mvz commented Jan 16, 2021

I can reproduce this. It seems my testing was lousy. I apologize.

@kyrylo
Copy link

kyrylo commented Feb 16, 2021

Can this be solved with an extend instead of monkey-patching?

@deivid-rodriguez
Copy link
Owner

Sorry for the delay here, I'll try to allocate some time soon to have a look. But yeah, it'd be great to find a solution that doesn't involve monkey-patching!

@bf4
Copy link

bf4 commented Feb 16, 2021

I'd be interested if you wanted to test the 'opt-in' plugin behavior in pry/pry#2177 since I didn't find much of a way to test it on my own

miharekar pushed a commit to peteromallet/Advisable that referenced this issue Feb 24, 2021
@sphynx79
Copy link

Same problem in Pry 0.14.1 how can i resolve this problem??

marcparadise added a commit to chef/chef that referenced this issue Jun 28, 2021
This permits `pry-byebug` to continue working with it, until
either pry/pry#2177 is merged,
or  deivid-rodriguez/pry-byebug#343 is
otherwise resolved.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
marcparadise added a commit to chef/chef that referenced this issue Jun 28, 2021
This permits `pry-byebug` to continue working with it, until
either pry/pry#2177 is merged,
or  deivid-rodriguez/pry-byebug#343 is
otherwise resolved.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
johnmccrae pushed a commit to chef/chef that referenced this issue Jul 16, 2021
This permits `pry-byebug` to continue working with it, until
either pry/pry#2177 is merged,
or  deivid-rodriguez/pry-byebug#343 is
otherwise resolved.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
@ned-pcs
Copy link

ned-pcs commented Jul 27, 2021

Despite having locked pry to 0.13.0, pry-byebug still gives me the UncaughtThrowError: uncaught throw :breakout_nav error.

@thomaswuensche said:

As a hacky fix, Pry.load_rc_files can be added to pry/lib/pry.rb. This will load .pryrc and therefore require pry-byebug before Pry is started.

Where would I add this? I'm greatly missing pry-byebug at the moment.

@ned-pcs
Copy link

ned-pcs commented Jul 27, 2021

OK, so I made my own version of the pry command that required pry-byebug early. I still get the same :breakout_nav error upon executing a pry-byebug command, despite having start_with_pry_byebug executed.

Here's my own pry command:

#!/usr/bin/env ruby
# frozen_string_literal: true
$0 = 'pry'
require 'byebug'
require 'pry-byebug'
require 'pry'

# Process command line options and run Pry
opts = Pry::CLI.parse_options
# Pry.load_rc_files # This doesn't seem to matter
Pry::CLI.start(opts)

Here's the stack when I invoke backtrace:

[25] pry(#<MyTopLevel>):2> backtrace
UncaughtThrowError: uncaught throw :breakout_nav
from /var/lib/gems/2.7.0/gems/pry-byebug-3.9.0/lib/pry-byebug/helpers/navigation.rb:15:in `throw'
(pry) output error: #<NoMethodError: private method `eval' called for nil:NilClass>
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:454:in `select_prompt'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:95:in `read'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:68:in `block in repl'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:67:in `loop'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:67:in `repl'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:38:in `block in start'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/input_lock.rb:78:in `with_ownership'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:38:in `start'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl_file_loader.rb:30:in `interactive_mode'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl_file_loader.rb:42:in `block in non_interactive_mode'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:300:in `show_result'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:672:in `block in handle_line'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_class.rb:382:in `critical_section'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:671:in `handle_line'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:261:in `block (2 levels) in eval'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:260:in `catch'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:260:in `block in eval'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:259:in `catch'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:259:in `eval'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl_file_loader.rb:46:in `block in non_interactive_mode'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl_file_loader.rb:45:in `each'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl_file_loader.rb:45:in `non_interactive_mode'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl_file_loader.rb:69:in `block in define_additional_commands'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/block_command.rb:15:in `instance_exec'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/block_command.rb:15:in `call'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/command.rb:495:in `call_with_hooks'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/command.rb:431:in `block in call_safely'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/command.rb:439:in `use_unpatched_symbol'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/command.rb:430:in `call_safely'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/command.rb:404:in `process_line'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/command_set.rb:354:in `process_line'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:328:in `process_command'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:361:in `process_command_safely'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:610:in `handle_line'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:261:in `block (2 levels) in eval'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:260:in `catch'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:260:in `block in eval'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:259:in `catch'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_instance.rb:259:in `eval'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:77:in `block in repl'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:67:in `loop'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:67:in `repl'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:38:in `block in start'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/input_lock.rb:61:in `__with_ownership'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/input_lock.rb:78:in `with_ownership'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:38:in `start'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/repl.rb:15:in `start'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/pry_class.rb:191:in `start'
/var/lib/gems/2.7.0/gems/pry-byebug-3.9.0/lib/pry-byebug/pry_ext.rb:13:in `start_with_pry_byebug'
/var/lib/gems/2.7.0/gems/pry-0.13.1/lib/pry/cli.rb:119:in `start'
utilities/pry:16:in `<top (required)>'

Byebug::PryProcessor#run is nowhere on this stack.

@jrochkind
Copy link

Any update on any chance of a pry-byebug that works with pry 0.14.0?

@bkuhlmann
Copy link

bkuhlmann commented Jan 10, 2022

Jonathan, not sure if this helps but you might want to switch to the new Ruby core Debug gem. You get all of Pry + Pry Byebug in a single gem now. I think the days of Pry are coming to an end.

@jrochkind
Copy link

Ah, I knew the debug gem replaced byebug, but i didn't realize it ended up replacing pry too? OK, good to know, thanks @bkuhlmann

@AlexWayfer
Copy link

you might want to switch to the new Ruby core Debug gem. You get all of Pry + Pry Byebug in a single gem now

I didn't find up command in the debug gem. Maybe there is lack of other byebug commands, not sure. Also, yes, pry is better for me than irb (colors, formatting, completion), so… it's an alternative, but not full-functional replacement.

@bkuhlmann
Copy link

🙇 Alexander. True, it's not a full functional replacement. Fair point.

@deivid-rodriguez
Copy link
Owner

deivid-rodriguez commented Aug 15, 2022

#386 should fix this, can someone confirm?

@andrehjr
Copy link

I've tested with pry 0.14.1 and pry-byebug 3.10.0 and had no issues.

Thanks @deivid-rodriguez !

@deivid-rodriguez
Copy link
Owner

Awesome, thanks for trying it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.