Skip to content

Commit

Permalink
Add require: "debug/prelude" after debug's Gemfile entry
Browse files Browse the repository at this point in the history
In ruby/debug#797, we found that requiring
`debug` automatically activates it, which could introduce runtime overhead
and cause memory bloat. And I think many users aren't aware of this and
could be taxed by this unnecessarily (e.g. having longer builds on CI).

Therefore, I propose to add `require: "debug/prelude"` after `debug`'s
Gemfile entry in the default Gemfile template. This way, users can
still use breakpoint methods like `debugger`, `binding.break`, and `binding.b`,
but the debugger won't be activated until a breakpoint is hit.
  • Loading branch information
st0012 committed Apr 30, 2024
1 parent 6a38d3a commit 142b8f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
* Generated Gemfile will include `require: "debug/prelude"` for the `debug` gem

Requiring `debug` gem directly automatically activates it, which could introduce
additional overhead and memory usage even without entering a debugging session.

By making Bundler require `debug/prelude` instead, developers can keep their access
to breakpoint methods like `debugger` or `binding.break`, but the debugger won't be
activated until a breakpoint is hit.

* Allow Actionable Errors encountered when running tests to be retried.

```txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gem "bootsnap", require: false

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri <%= bundler_windows_platforms %> ]
gem "debug", platforms: %i[ mri <%= bundler_windows_platforms %> ], require: "debug/prelude"
<%- unless options.skip_brakeman? -%>

# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
Expand Down

0 comments on commit 142b8f7

Please sign in to comment.