pry-byebug: Newest version of Pry breaks pry-byebug

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 https://github.com/deivid-rodriguez/pry-byebug/blob/34ba6766d998d934169cd5e4887da2b69a884cde/lib/pry-byebug/pry_ext.rb#L17 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?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

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!

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