72

The latest version of irb introduced an autocomplete that is quite buggy and I don't generally like to be distracted by an autocomplete, any idea how I can disable it?

Related question: How to disable Pry autocomplete?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
Dorian
  • 7,749
  • 4
  • 38
  • 57

3 Answers3

81

Try putting this in your ~/.irbrc

IRB.conf[:USE_AUTOCOMPLETE] = false
mu is too short
  • 426,620
  • 70
  • 833
  • 800
vkozyrev
  • 1,770
  • 13
  • 13
  • Perfect, it works, thanks a lot – Dorian Dec 28 '21 at 17:23
  • @Dorian could you accept my answer? – vkozyrev Feb 14 '22 at 15:52
  • 1
    sorry just did, thanks again for the answer, I also added `IRB.conf[:ECHO_ON_ASSIGNMENT] = true` – Dorian Feb 15 '22 at 09:23
  • 2
    I did not have an `~/.irbrc` file so I created it and put `IRB.conf[:USE_AUTOCOMPLETE] = false` and `require "irb/completion"` in it, saved and restarted the terminal but it is still auto suggesting, can you tell me what I am missing. – Ricky Apr 28 '22 at 12:54
  • something recently happened, pasting code into the console is triggering auto complete. This helps – Varun Garg May 06 '22 at 08:06
  • 2
    You can also put the `.irbrc` file in your repo directory and it will work for all Users and in Production/Staging/etc. – Joshua Pinter Sep 13 '22 at 21:53
  • @Ricky did you create it as a file or directory? In my case I just created it as a file in the home directory and add `IRB.conf[:USE_AUTOCOMPLETE] = false` and it works. – Erick Jan 01 '23 at 01:29
  • Despite what the docs suggest, having the `.irbrc` file in my project's root folder did nothing. It does work when in my home directory though. – JP Duffy Apr 17 '23 at 15:28
37

We can pass the --noautocomplete command line option when invoking IRB.

irb --noautocomplete

Alternatively we can set a configuration option in ~/.irbrc or one of the other locations specified in the documentation

IRB.conf[:USE_AUTOCOMPLETE] = false

Starting a Rails console will respect this configuration but for a one-off we can provide the command line option. Be sure to pass any Rails options before the --

rails console --sandbox -- --noautocomplete
HarlemSquirrel
  • 8,966
  • 5
  • 34
  • 34
9

If you using IRB remotely and do not have permission to update .irbrc file, try this:

Reline.autocompletion = IRB.conf[:USE_AUTOCOMPLETE] = false

This assignment changes the behaviour of the current session.

May the source be with you.