Skip to content
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

Allow disabling autocompletion with IRB_USE_AUTOCOMPLETE=false #469

Merged
merged 2 commits into from
Dec 6, 2022

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Dec 3, 2022

Currently, the only 2 ways to disable autocompletion are:

  1. Create .irbrc and set IRB.conf[:USE_AUTOCOMPLETE] = false
  2. Add the --noautocomplete flag when using the irb executable

Both of them are less convenient than setting a env var and are lesser known to devs.

And given the number of problems the autocompletion has (see #445), I think we should allow disabling it with a simple IRB_USE_AUTOCOMPLETE=false.

@st0012 st0012 changed the title Allow using USE_AUTOCOMPLETE=false to disable autocompletion Allow disabling autocompletion with USE_AUTOCOMPLETE=false Dec 5, 2022
@st0012 st0012 force-pushed the expose-use-autocomplete-env branch from ab6fe42 to 4cf3b42 Compare December 5, 2022 12:56
@st0012
Copy link
Member Author

st0012 commented Dec 5, 2022

cc @k0kubun

@k0kubun
Copy link
Member

k0kubun commented Dec 5, 2022

Both of them are less convenient than setting a env var and are

It depends. ~/.irbrc is scoped to IRB, and --noautocomplete is scoped to each IRB invocation. Having USE_AUTOCOMPLETE in your shell could impact any other non-IRB program. Global variables are "convenient" but it doesn't necessarily mean it improves maintainability. I would still use ~/.irbrc even after this is merged.

I like that you chose a name consistent with irbrc, but when it comes to environment variables, I would choose a name that includes IRB to avoid possible namespace conflicts.

lesser known to devs.

How will it be easier to know of this environment variable than .irbrc or --noautocomplete?

And given the number of problems the autocompletion has (see #445), I think we should allow disabling it with a simple USE_AUTOCOMPLETE=false.

If it's that problematic, we might want to consider disabling it by default until all the issues are addressed. The most annoying part of auto-completion for me is the fact that the prompt position randomly moves depending on the completion size when you're at the bottom of the window, but currently nobody even discusses it maybe because there are more annoying problems for other people.

I appreciate that reline-powered IRB supports multi-line editing and can be used like an editor, but I still use one-liner inputs on IRB most of the time. It's never easier to edit a multi-line long script on reline than your own actual editor. If you mostly use a one-liner, it feels more like a normal REPL than an editor. It's normal to have auto-completion on an editor, but not on a REPL. While it might be useful for some people to have this capability, I don't think this needs to be enabled by default, especially when it's a factor that annoys IRB users.

@st0012
Copy link
Member Author

st0012 commented Dec 5, 2022

I like that you chose a name consistent with irbrc, but when it comes to environment variables, I would choose a name that includes IRB to avoid possible namespace conflicts.

We can use the same prefix convention debug uses, which would be RUBY_IRB_USE_AUTOCOMPLETE.

How will it be easier to know of this environment variable than .irbrc or --noautocomplete?

I think I should phrase it differently: in my experience, env var is a common way to control features like this (such as NO_COLOR, which IRB also supports). So if given no guidance on how to configure the feature, I'd look for related env vars first.

If it's that problematic, we might want to consider disabling it by default until all the issues are addressed.

I thought about it before. But based on my polling result in #445, we have around 28% of users satisfied with it as it is today. And only 17% of them dislike it enough to disable it. So if we disable it now, it'd be a breaking change for the 28% of users, which is a big number.

Therefore, I think we should keep it enabled, but also make it easier to disable. That's why I want to propose this env var.

@k0kubun
Copy link
Member

k0kubun commented Dec 5, 2022

Fair enough.

We can use the same prefix convention debug uses, which would be RUBY_IRB_USE_AUTOCOMPLETE.

It makes sense that debug.gem needs to start it with RUBY_ because "debug" is not unique to Ruby, but for IRB, I guess it's fine to just use IRB_ since RB is Ruby and fairly unlikely to conflict on a shell, especially when you were okay with prefixing nothing. FYI Bundler uses BUNDLE_GEMFILE and BUNDLE_JOBS. WDYT about calling it IRB_USE_AUTOCOMPLETE?

@st0012 st0012 force-pushed the expose-use-autocomplete-env branch from 4cf3b42 to a7dfd1b Compare December 6, 2022 00:00
@st0012
Copy link
Member Author

st0012 commented Dec 6, 2022

IRB_USE_AUTOCOMPLETE sounds good, updated 👍

@k0kubun k0kubun changed the title Allow disabling autocompletion with USE_AUTOCOMPLETE=false Allow disabling autocompletion with IRB_USE_AUTOCOMPLETE=false Dec 6, 2022
@st0012 st0012 force-pushed the expose-use-autocomplete-env branch 2 times, most recently from 56e4194 to 1ffaeca Compare December 6, 2022 00:28
lib/irb/init.rb Outdated Show resolved Hide resolved
Currently, the only 2 ways to disable autocompletion are:

1. Create `.irbrc` and set `IRB.conf[:USE_AUTOCOMPLETE] = false`
2. Add the `--noautocomplete` flag when using the `irb` executable

Both of them are less convenient than setting a env var and are
lesser known to devs.

And given the number of problems the autocompletion has (see ruby#445), I
think we should allow disabling it with a simple `IRB_USE_AUTOCOMPLETE=false`.
@st0012 st0012 force-pushed the expose-use-autocomplete-env branch from 1ffaeca to 0547fa3 Compare December 6, 2022 00:43
@k0kubun k0kubun merged commit a6648bf into ruby:master Dec 6, 2022
matzbot pushed a commit to ruby/ruby that referenced this pull request Dec 6, 2022
`IRB_USE_AUTOCOMPLETE=false`
(ruby/irb#469)

* Allow using IRB_USE_AUTOCOMPLETE=false to disable autocompletion

Currently, the only 2 ways to disable autocompletion are:

1. Create `.irbrc` and set `IRB.conf[:USE_AUTOCOMPLETE] = false`
2. Add the `--noautocomplete` flag when using the `irb` executable

Both of them are less convenient than setting a env var and are
lesser known to devs.

And given the number of problems the autocompletion has (see #445), I
think we should allow disabling it with a simple `IRB_USE_AUTOCOMPLETE=false`.

* Mention some env var configs in the README
@st0012 st0012 deleted the expose-use-autocomplete-env branch December 6, 2022 13:59
st0012 added a commit to Shopify/rails that referenced this pull request Dec 6, 2022
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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants