brew install (or upgrade, reinstall) a single, official formula (not cask)? brew update and can still reproduce the problem?brew doctor, fixed all issues and can still reproduce the problem?brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?I prefer to use the git completion from zsh rather than the bundled completion that comes with the git package. Unfortunately, f710a1395 removes to option to omit the bundled completion files from the git package and places the completion function in a path that is preferred to what ships with zsh.
These are the directories in question:
$ zsh -c 'print -l $fpath'
/usr/local/share/zsh/site-functions
/usr/local/Cellar/zsh/5.6.2_1/share/zsh/functions
The first (preferred) directory is the location the completion file (_git) from the git package is installed to. The second one contains the more advanced completion shipped with zsh (also _git).
The commit message of f710a1395 does not explain why the --without-completions option was removed nor how to work around it.
The only workaround I found is to move the zsh/<version> element to the beginning of the array which is a rather nasty hack:
fpath[$fpath[(i)/usr/local/Cellar/zsh/5.6.2_1/share/zsh/functions]]=()
fpath=(/usr/local/Cellar/zsh/5.6.2_1/share/zsh/functions $fpath)
While this works it makes is impossible to have selective overrides for zsh-bundled completions.
$ cd "$(brew --repository)"
$ git checkout f710a1395 -- Formula/git.rb
$ brew install git --without-completions
==> Downloading https://homebrew.bintray.com/bottles/git-2.18.0.mojave.bottle.tar.gz
...
$ ls -la /usr/local/share/zsh/site-functions/_git
lrwxr-xr-x 1 agross admin 58 Oct 22 22:28 /usr/local/share/zsh/site-functions/_git -> ../../../Cellar/git/2.19.0_1/share/zsh/site-functions/_git
# => override installed
$ cd "$(brew --repository)"
$ git checkout f710a1395~ -- Formula/git.rb
$ brew reinstall git --without-completions
==> Downloading https://www.kernel.org/pub/software/scm/git/git-2.18.0.tar.xz
...
$ ls -la /usr/local/share/zsh/site-functions
ls: cannot access '/usr/local/share/zsh/site-functions/_git': No such file or directory
# => override not installed
Homebrew is removing options based on limited usage (as we see it in the analytics here: https://formulae.brew.sh/analytics/). These options provide a lot of reasons for builds to break and aren't tested.
In your specific case the best option might be to improve zsh autocomplete for everyone by contributing it to git. If you prefer to keep the option you'll have to use brew extract to copy the git formula to a tap.
Another option is to hard-code the formula to install only the bash completion by default. Anyone using zsh will then automatically get the better completion provided by zsh itself. Anyone using bash will get the completion provided by git.
@agross Yes, but if we hard-code it we should do it every time the git formula is updated, correct?
Not sure what you mean by "everytime the formula is updated". If you mean installing the bash completion for the respective git version that is installed, then yes, do that. It's what the current formula does as well. But please omit the _git symlink.
Which ZSH completion (the one provided by ZSH or the one provided by Git) is up for debate and as a result I think we should defer to installing both versions and require users to manually configure which one they wish to use. I personally use Git and ZSH pretty heavily and am happy with Git's ZSH completion.
Not sure what you mean by "everytime the formula is updated". If you mean installing the bash completion for the respective git version that is installed, then yes, do that. It's what the current formula does as well. But please omit the
_gitsymlink.
@agross Sorry but I didn't understand, every time git updates what should I do to get the working zsh completions back?
@gmcinalli You as a brew package author or you as a zsh+git user?
@MikeMcQuaid zsh installs its version when you install zsh. There is no option to disable that.
The git package overrides it with an inferior version, that is what I'm trying to resolve here. We had an option to decide upon this which was taken away from me and others.
What I suggest is from my perspective what you suggest: You can decide whether you want to use the inferior version by adding git's packaged (inferior) completion to your zsh fpath.
The git package overrides it with an inferior version, that is what I'm trying to resolve here.
That is your opinion and it's not universally held. In general we defer to what upstream does.
@agross Sorry, me as a zsh+git user.
@gmcinalli I remove /usr/local/share/zsh/site-functions/_git on every invocation of the shell.
@MikeMcQuaid
In general we defer to what upstream does.
Who is upstream, zsh or git? What does the upstream "do" in this case? Both provide a file, git as a "contrib" file, zsh as a core file.
If git's completion file is not doing a good job, surely the better path forward, for all involved, is to contribute to them a better version?
A couple of thoughts:
The zsh completion that ships with git (as a contrib) isn’t just subjectively bad, it’s objectively broken. Just one example: try to create a file with a space in its name and try to complete that filename in a git add. It won’t escape the space.
The zsh completion in git’s contrib appears to be unmaintained. (From appearances, it looks like the git project doesn’t really care much about zsh _per se_, but zsh cares that git works well under it.)
Writing (and _maintaining_) a zsh completion script is a rather arcane and specialised bit of wizardry. I couldn’t "just do it", and I’d like to think I know more than average about using zsh.
Contributing zsh completion to git seems like duplicate work when the zsh project already provides and maintains perfectly workable git completion. (The best one could do would be to convince the git folks to include the completion script provided by zsh, but why would they do it when anyone using zsh already has that completion by definition?)
From my (limited) experience, git development is an extremely hard community to break into. It’s not an easy project to contribute to … certainly, you can’t just make a GitHub pull request and hope for the best; that’s not how they work. (The GitHub repo is just a mirror.)
My preferred solution would be to just stop installing the git/contrib completion script from the recipe, and rely on the completion that ships with zsh.
Who is upstream, zsh or git? What does the upstream "do" in this case? Both provide a file, git as a "contrib" file, zsh as a core file.
Upstream is Git. They provide ZSH completion which we install.
- The zsh completion that ships with git (as a contrib) isn’t just subjectively bad, it’s objectively broken. Just one example: try to create a file with a space in its name and try to complete that filename in a
git add. It won’t escape the space.
Again: I use Git's ZSH completion and have for years and it works well for me. You can point out bugs in any software; that doesn't mean they are "objectively broken".
I agree with @fxcoudert here that the best options here involve discussions with the upstream Git and/or ZSH projects. Homebrew is not modifying any installed files.
Closing now. The issue with git's completion file should be reported to git and discussed with them. They can fix it, in which case everyone will benefit, or drop it, in which case the issue is also fixed.
Most helpful comment
A couple of thoughts:
The zsh completion that ships with git (as a contrib) isn’t just subjectively bad, it’s objectively broken. Just one example: try to create a file with a space in its name and try to complete that filename in a
git add. It won’t escape the space.The zsh completion in git’s contrib appears to be unmaintained. (From appearances, it looks like the git project doesn’t really care much about zsh _per se_, but zsh cares that git works well under it.)
Writing (and _maintaining_) a zsh completion script is a rather arcane and specialised bit of wizardry. I couldn’t "just do it", and I’d like to think I know more than average about using zsh.
Contributing zsh completion to git seems like duplicate work when the zsh project already provides and maintains perfectly workable git completion. (The best one could do would be to convince the git folks to include the completion script provided by zsh, but why would they do it when anyone using zsh already has that completion by definition?)
From my (limited) experience, git development is an extremely hard community to break into. It’s not an easy project to contribute to … certainly, you can’t just make a GitHub pull request and hope for the best; that’s not how they work. (The GitHub repo is just a mirror.)
My preferred solution would be to just stop installing the git/contrib completion script from the recipe, and rely on the completion that ships with zsh.