gradle-completion icon indicating copy to clipboard operation
gradle-completion copied to clipboard

Basic installation doesn't work on macOS with zsh

Open ZacSweers opened this issue 4 years ago • 5 comments

❯ brew install gradle-completion

❯ echo $fpath | grep "/usr/local/share/zsh/site-functions"
/Users/zsweers/.oh-my-zsh/plugins/git /Users/zsweers/.oh-my-zsh/functions /Users/zsweers/.oh-my-zsh/completions /usr/local/share/zsh/site-functions /usr/share/zsh/site-functions /usr/share/zsh/5.7.1/functions

cd <our project>

❯ source ~/.zsh/gradle-completion/_gradle 1>&2 2>/dev/null; __gradle-completion-init
zsh: command not found: __gradle-completion-init

~/.zsh/gradle-completion doesn't exist, is there some undocumented intermediary step required?

ZacSweers avatar Aug 04 '20 20:08 ZacSweers

Try quitting Terminal and re-opening it. This was a required step that I had to do to get it to work properly.

mdemaso avatar Aug 10 '20 15:08 mdemaso

The issue is that the manual install step would put the _gradle file in this spot: ~/.zsh/gradle-completion/_gradle. However, running brew install gradle-completion puts the file in /usr/local/share/zsh/site-functions/_gradle.

So if you run source /usr/local/share/zsh/site-functions/_gradle 1>&2 2>/dev/null; __gradle-completion-init. Then it'll work.

I ran into this same issue :).

Edit: Running ./gradlew will also generate the cache of course

jkaan avatar Oct 26 '20 09:10 jkaan

I am getting this error

% source /usr/local/share/zsh/site-functions/_gradle
_gradle:6: command not found: _arguments
__gradle_tasks:20: command not found: _describe

After which I can't get autocomplete working following the above steps or the troubleshooting steps in readme 😞

tinder-haroldmartin avatar Jun 07 '21 20:06 tinder-haroldmartin

I'm running into the same problem! Is homebrew not the recommended way to install gradle-completion?

saket avatar Feb 01 '22 19:02 saket

just add following snippet to your .zshrc

if [ $commands[brew] ]
then
  fpath=("$(brew --prefix)/share/zsh/site-functions" $fpath)
fi

see https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh

qoomon avatar Jun 24 '22 15:06 qoomon