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
Incompatibility with Zeitwerk #564
Comments
Hi @fxn! Thanks for Byebug uses the Tracepoint API very heavily, including |
Exactly, I was wondering that too. I am trying to reproduce, and apparently the description is not accurate. The If you clone and
Mystery! If you'd like to modify the block to debug, the tracer is defined here. |
Thanks for the reproduction steps, I'll see if I can figure it out! |
Ah! I forgot @palkan investigated this and left some comments in fxn/zeitwerk#31 (comment). |
This is a minimal reproduction that does not depend on Rails or Zeitwerk:
We should see |
Nice. Yeah, after reading the message you linked to I understood the problem, and I think it should be fixable inside |
Hei @fxn! So I had a closer look at this yesterday and managed to narrow down the problem. In principle, I think the solution belongs in ruby-core 😞. I think the reason why this doesn't work is the same reason why the following script TracePoint.trace(:class) do |_tp|
puts "CLASS"
end
# trigger a class event
binding.eval("class Hola; end")
TracePoint.trace(:line) do |tp|
puts "LINE"
# trigger a class event, ignored :(
tp.binding.eval("class Adios; end")
end
# trigger a line event
1 + 1 prints
instead of
The problem is that when we are in the debugger prompt, we're actually in the middle of a See https://github.com/ruby/ruby/blob/02880d1f4a9ebd1c0a807376fcb25ccd908334b4/vm_trace.c#L383-L400. A potential solution would be to allow some level of reentrancy by keeping a stack instead of a single flag, and check that the current event type is not already in the stack. That would allow I'll bring this to ruby-core. |
Just wondering if there is any intention to support this? Moving project to 'break' at this point. Wondering if you've considered adopting whatever approach they are using? |
Sorry, I haven't had any chance to work on this, but I'd love to support it of course! Contributions welcome! |
Link to the Ruby issue about this: https://bugs.ruby-lang.org/issues/15912 |
Does anyone know what's the trick that |
@eregon if my memory does not fail me, it has to do with running things in different fibers /cc @gsamokovarov. |
This approach has its drawbacks as well. You can't debug code in a fiber initiated by another thread. The nice thing about the approach is that it can be done in another layer of the debugger, say closer to the REPL itself rather than the actual internals. |
ruby/debug is a new debugger that is going to ship with CRuby. It makes sense for Rails to switch to this one because that is where the language is heading, and because Byebug is not fully compatible with Zeitwerk. See deivid-rodriguez/byebug#564 While ruby/debug has not been heavily tested with Zeitwerk, casual usage seems to suggest it works without issues, including explicit namespaces, which is where Byebug and Zeitwerk conflict. Byebug is terrific, thanks a lot for all these years. ❤️
ruby/debug is a new debugger that is going to ship with CRuby. It makes sense for Rails to switch to this one because that is where the language is heading, and because Byebug is not fully compatible with Zeitwerk. See deivid-rodriguez/byebug#564 While ruby/debug has not been heavily tested with Zeitwerk, casual usage seems to suggest it works without issues, including explicit namespaces, which is where Byebug and Zeitwerk conflict. Byebug is terrific, thanks a lot for all these years. ❤️
Seems that |
@d4rky-pl as far as I’m aware, yes. the same issue affected the debug gem and was fixed by the use of |
@brasic unfortunately the TracePoint part in byebug is implemented in C which is way above my pay grade so I can't contribute 🥲 Here's hoping someone will be interested in picking this up. I really love byebug and pry and can't imagine working without them. It's probably one of the most important libraries in my developer career 😅 |
Hey guys I came up with a solution. Your reviews & testing are welcome #847 @deivid-rodriguez please |
I kept hitting this undefined constant error, see deivid-rodriguez/byebug#564 to use debug insert `binding.break`
I kept hitting this undefined constant error, see deivid-rodriguez/byebug#564 to use debug insert `binding.break`
Let me open this issue as a way to exchange impressions about this.
Zeitwerk listens to
:class
events to load what the project calls "explicit namespaces" (see why at this moment in my talk in RailsConf), but within a Byebug session, these events are not emitted.Does Byebug need specifically to disable
:class
events, or could it disable others and preserve this one? If it needs them, could it be a way to make both projects compatible?Right now, Rails 6 applications with common defaults have this gotcha, for example.
The text was updated successfully, but these errors were encountered: