-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Disable Rails console IRB's autocompletion in production by default. #46656
Disable Rails console IRB's autocompletion in production by default. #46656
Conversation
Reasons behind this change: 1. Autocompletion increases data transmission significantly. This could cause noticeable slowdown when connecting to remote servers, which is usually the case in production. 2. The autocompletion feature still has many issues, as listed in ruby/irb#445. They may be just annoying when happened locally, but in production they could cause real issues (e.g. typos caused by slow backspacing). Due to these reasons, I think it's safer to disable this feature in production. About the implementation: Because `IRB.start` doesn't take configuration arguments and rebuilds the `IRB.conf` object, the only way we can turn off autocompletion is through the `IRB_USE_AUTOCOMPLETE` env var. The env var was added in ruby/irb#469 and will be available for IRB 1.6+ and Ruby 3.2+. The name wasn't used before so it won't cause issues with older IRB versions. Note: Users can still turn it back on with `IRB_USE_AUTOCOMPLETE=true`
In #46656 we disable the IRB autocompletion if it's production. The original PR used `== "production"` but it's cleaner if we use the `production?` helper instead.
…production Disable Rails console IRB's autocompletion in production by default.
In #46656 we disable the IRB autocompletion if it's production. The original PR used `== "production"` but it's cleaner if we use the `production?` helper instead.
Thanks @st0012, I complained a lot about this completion when connecting to production servers (and locally to a smaller extent) and wondered if I was the only one, apparently not :) |
great PR. thanks! |
@@ -38,6 +38,10 @@ def initialize(app, options = {}) | |||
|
|||
if @console == IRB | |||
IRB::WorkSpace.prepend(BacktraceCleaner) | |||
|
|||
if Rails.env == "production" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not use Rails.env.production?
or even reverse the logic and set this only in development so all other environments (for example I have seen staging
environment used often) will not be affected by completion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would agree with the idea of reversing it and only enable it by default on development.
in a perfect world, i would disable it for all environments and let the dev decide when to enable it, explicitly. either via development.rb
or ENV var
Motivation / Background
Due to these reasons, I think it's safer to disable this feature in production.
Detail
Because
IRB.start
doesn't take configuration arguments and rebuilds theIRB.conf
object, the only way we can turn off autocompletion is through theIRB_USE_AUTOCOMPLETE
env var.The env var was added in ruby/irb#469 and will be available in IRB 1.6+ and Ruby 3.2+. The name wasn't used before so it won't cause issues with older IRB versions.
Additional information
Users can still override this by setting
IRB_USE_AUTOCOMPLETE=true
.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]