'How to continue without breakpoints in Byebug
Using the byebug gem gives me the ability to continue until the next breakpoint:
(byebug) help
break -- Sets breakpoints in the source code
catch -- Handles exception catchpoints
condition -- Sets conditions on breakpoints
continue -- Runs until program ends, hits a breakpoint or reaches a line
delete -- Deletes breakpoints
disable -- Disables breakpoints or displays
display -- Evaluates expressions every time the debugger stops
down -- Moves to a lower frame in the stack trace
edit -- Edits source files
enable -- Enables breakpoints or displays
finish -- Runs the program until frame returns
frame -- Moves to a frame in the call stack
help -- Helps you using byebug
history -- Shows byebug's history of commands
info -- Shows several informations about the program being debugged
interrupt -- Interrupts the program
irb -- Starts an IRB session
kill -- Sends a signal to the current process
list -- Lists lines of source code
method -- Shows methods of an object, class or module
next -- Runs one or more lines of code
pry -- Starts a Pry session
ps -- Evaluates an expression and prettyprints & sort the result
quit -- Exits byebug
restart -- Restarts the debugged program
save -- Saves current byebug session to a file
set -- Modifies byebug settings
show -- Shows byebug settings
source -- Restores a previously saved byebug session
step -- Steps into blocks or methods one or more times
thread -- Commands to manipulate threads
tracevar -- Enables tracing of a global variable
undisplay -- Stops displaying all or some expressions when program stops
untracevar -- Stops tracing a global variable
up -- Moves to a higher frame in the stack trace
var -- Shows variables and its values
where -- Displays the backtrace
I looked all over and I cannot find a way to "continue without breakpoints". The only way I can think of is to remove or comment the byebug statements, quit with q! and restart the test.
How can I continue without stopping at other byebug statements in Ruby?
Solution 1:[1]
You can use continue! or alias c! since byebug 11.0.0.
See this PR https://github.com/deivid-rodriguez/byebug/pull/524
If you are working with Rails, you may wanna reset it back on new request, than you can add a filter:
# application_controller.rb
before_action do
if defined?(Byebug) && Byebug.mode == :off && Rails.env.development?
Byebug.mode = nil
end
end
Solution 2:[2]
A byebug method call in your code is not a 'breakpoint' (thinking of the references to breakpoint in the help output).
As per the help output, breakpoints can be disabled with the disable command. But that does not solve your problem because the next byebug will pause execution again.
Since byebug is just a method call, you can make it conditional:
byebug if SomeModule.byebug?
Then, in SomeModule, you could use a global variable to toggle it on/off. You'd either have to do that on all your calls to byebug, or you could monkey-patch the byebug method to do the same, alias_method_chain or something similar.
"Make Byebug finish executing without exiting Pry" is a similar answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Community |
