brew: tab-completing formula names is very slow

Please follow the general troubleshooting steps first:

  • [*] Ran brew update and retried your prior step?
  • [*] Ran brew doctor, fixed as many issues as possible and retried your prior step?

Bug reports:

tab-completion of formula names is very slow (many seconds), after updating to brew 0.9.9. I only have the core tap installed.

I’m actually unsure if these completions were already slow before, as I hadn’t triggered one for a while before this latest update.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I figured out the problem. We’re getting differing results because some of us have an old completion script for homebrew that is getting loaded in addition to the new one.

Everyone, check your $(brew --prefix)/etc/bash_completion.d/ directory for any other files starting with ‘brew’. There should be exactly one file, which is called simply ‘brew’. I found I had a ‘brew_bash_completion.sh’ and ‘brew_bash_completion.sh.default’ AND ‘brew_bash_completion.sh.default.save’ in that directory. They’re leftovers from brew-legacy. Or something. I don’t know where that .save came from. Maybe I caused it, or maybe other people have it, just check for any suspicious files with brew in the name. Leave only the file named ‘brew’.

One removed, the speed issues immediately go away while all completions continue to work. You probably will want to open a fresh shell to test.

And @tdsmith is right, the brew bash completion script appears to have been optimized, so anyone who had an unpolluted bash_completion.d directory (bash_completion automatically loads everything in that directory) would see exactly what @tdsmith sees: a slightly faster brew tab completion.

The old completion scripts do some things that result in very inefficient completion if there are a large number of formulae in a tap. Before the split, this was fine, as there would not be a huge number of formulae there. Now however, having 3500 Formulae in the taps folder makes the old completion script basically unusable.

I have no idea how or why those old files are there, but I think its just a case of a tiny detail getting overlooked.

Man, I am so happy to have my completions back. Fast as ever now!

@pavelrad @metacollin Glad to hear it. We could/should perhaps have Homebrew remove them for you.