-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add a command to activate and switch to ruby/debug
console
#425
Comments
Did you conclude it's impossible to make IRB work like pry-byebug? On pry-byebug, you don't need to explicitly switch to byebug to use some of the byebug features. Requiring users to run |
I didn't conclude it's "impossible". But it is more difficult because But more importantly, what you proposed is not mutually exclusive with this proposal: In |
When you want to use all the debug.gem commands, why don't you start You said Is this proposal primarily targeting other users, e.g. gem/library developers? I feel like we have more users who are application developers, and I think they should not use this feature ( |
In summary, my proposal is:
|
This only applies to some Rails apps though. In my previous and current company's apps, we don't want This is because I don't think this experience applies to the majority of Rails devs. But if we just look at Shopify, all major Rails apps have And as you said, library developers would need to manually require it too.
I don't mean people would use it every time they want to debug something. Personally, I always throw I think it's a feature like
I think it's a good idea. But I'm also curious about more details you have in mind. Like, should it be another gem? Or it should be baked in Maybe we can have another issue for this? |
I changed my mind. I support adding this to IRB in Ruby 3.2. Since you already have a working demo, can you make https://github.com/st0012/irb/commits/irb-debug a pull request so that we can merge it first and improve it from there as needed?
I spent a couple of nights experimenting with this idea. I have a working-ish seamless implementation of Also, while working on it, I noticed that all of these commands need to share an implementation to start the Because of the complexity and the portion that will be shared anyway, I think it's more reasonable/realistic to introduce what you're proposing first.
While I still think pry-byebug -like integration is more useful, I do agree that your proposal is a good enough solution to those problems too. Now that I understand my idea is a long shot for Ruby 3.2, I'd rather like to see Ruby 3.2 with the feature you proposed as an alternative. Let's do this! Finally, as to the discussion points you raised:
+1 on
Agreed.
I'm still disabling autocompletion (which would remain as is at least until https://bugs.ruby-lang.org/issues/18996 is added), so I don't have any preference yet. Please implement what feels the most convenient for you. |
Background
When debugging programs with Ruby 2.7+ , it's common to start with adding
binding.irb
breakpoints in the code. This is becauseirb
is the only console-based tool (including REPLs and debuggers) that doesn't require installation nor require.However, because
irb
is a REPL and lacks debugger features like step-debugging, frame navigation...etc., users may need to switch to debuggers like ruby/debug for advanced debugging.And currently, that switch looks like this:
irb
session.require "debug"
if it's not yet required.binding.irb
withruby/debug
's breakpoints likebinding.b
ordebugger
(they're the same).It's a 4-step process and requires switching between terminal and editor.
During a discussion with @k0kubun, he mentioned that maybe
irb
can help reduce the pain.Proposal
Add a new
debug
command toirb
, which when being executed willrequire "debug/session"
and start the debugger.LoadError
, it means the newdebug
gem is not installed. So it will print a message to remind the user instead.irb
session with a newdebug
console.binding.irb
was placed.With this command, a user's
irb
->debug
switch would be:debug
in theirb
session.Demo
Discussion Points
debug
ordebugger
?debug
:debugger
:debugger
statementruby/debug
already has.irb
.irb
?irb
registers autocompletion logic toreline
,debug
's console (also powered byreline
) will inherit that too.The text was updated successfully, but these errors were encountered: