0x2c7/ruby_jard

[BUG] Seems to break "binding.pry"

kikonen opened this issue · 4 comments

Describe the bug
Tried to evaluate "jard", but since simply installing "ruby_jard" gem broke usage of "binding.pry" as breakpoint, had to uninstall "ruby_jard".

To Reproduce
Steps to reproduce the behavior:

  1. add "binding.pry" breakpoint in rails app
  2. Hit breakpoint

=> error when breakpoint is hit

before_session hook failed: UncaughtThrowError: uncaught throw :jard_control_flow
//.rvm/gems/ruby-2.6.6@drt_ui/gems/ruby_jard-0.3.0/lib/ruby_jard/control_flow.rb:53:in `throw'
(see pry_instance.hooks.errors to debug)
0x2c7 commented

Hi @kikonen, thanks for reporting. This issue is mentioned in #39, and already fixed in #41. Unfortunately, I haven't release a new version yet. So, in the meantime, you can install the gem pointing directly to this repo's master branch.

gem 'ruby_jard', group: :development, git: 'https://github.com/nguyenquangminh0711/ruby_jard'

I'll comment in this issue when the patched version is released.

yes, that problem is seemingly fixed there

Nope, actually doesn't work always

howto

  • "jard" breakpoint in line
  • execute action in rails app
  • hit breakpoint and continue
  • replace breakpoint to be "binding.pry"
  • execute action in rails app
    => "jard_control_flow" error hit

And seemingly after this is hit, have to force exit pry session via "!!!" and then kill and restart rails server

0x2c7 commented

@kikonen Yeah, that's kinda a limitation. I mentioned in one of the issue links above:

The limitation is that after jard is first triggered, the backward compatibility is not guranteed anymore. The reason is that after Jard starts, it takes over internal states of Pry and Byebug. So, byebug and pry are not awared of external changes, and won't work as expected. If Jard doesn't start, they are fine.

When you do a live-reloading, the reloading engine replaces the content of the file you injected, Jard configuration stays intact. So, when binding.pry is triggered with Jard-specific configurations. Overcoming this limitation is not possible now. Both Byebug and Pry somehow depends on the global configurations. In further future, I may make some contributions to them to fix this issue forever.