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

zsh:12: command not found: __tig_main #940

Closed
r2099c2 opened this issue Jun 28, 2019 · 13 comments
Closed

zsh:12: command not found: __tig_main #940

r2099c2 opened this issue Jun 28, 2019 · 13 comments

Comments

@r2099c2
Copy link

r2099c2 commented Jun 28, 2019

image

It happened When I input tig and then tap ‘tab’ button.

zsh:12: command not found: __tig_main

Some info:

  • I install tig use homebrew.
  • use zsh & oh-my-zsh with init .zshrc file (only add nvm)
tig --version

tig version 2.4.1
ncurses version 5.7.20081102
readline version 8.0

git --version

git version 2.22.0
@Garonenur
Copy link

I have/had the same problem.

I installed the completion file from this repository to ~/.completion but it did not work.

reading in the logs of zsh -lx I saw that some _git completion file was loaded and defined _tig I found this in /usr/share/zsh/functions/Completion/Unix/_git which is probably different for you, but it might hint in the right direction.
I renamed that file so it gets ignored by zsh-completion and now the completion file that comes with this repo is used as advertised.

@koutcher
Copy link
Collaborator

@rohieb proposed an updated version of the completion for tig in #960, could you give it a try with zsh ?

@ahmedre
Copy link

ahmedre commented Jan 14, 2020

tried the updated version of completion and it didn't help - but likely not because of that PR itself, since the issue seems to be coming from something else.

as @Garonenur mentions, if I remove the _git file located in /usr/local/share/zsh/site-functions/_git(this is where Homebrew installs it), then completion works as expected.

i suspect the reason has to do with the bottom of _git, where, within the _git() method, it says:

        if (( $+functions[__${service}_zsh_main] )); then
                __${service}_zsh_main
        else
                emulate ksh -c __${service}_main
        fi

the emulate ksh line is what causes it to look for __tig_main (as evidenced by commenting out that line no longer giving the same error, but also not doing any completion for tig). i am not sure why pressing tab on tig kicks off the _git() method though.

@Garonenur
Copy link

our workaround is not working for me anymore, I removed the _git file that came with ubuntu (WSL) and I have git and tig compiled from source, the respective completion files are in my $fpath (I use zsh).
If I have the system installed _git I get the above mentioned error, __tig_main not found. If I remove that _git file, and thus only have the one from gits github source I now get tig-completion.bash:98: command not found: __git_complete the first time I try completion and

_tig:3: parse error: condition expected: 1
_tig:30: command not found: __git_complete_command
_tig:31: command not found: __gitcompappend

the second time I tap tab.

@Garonenur
Copy link

this part of the code:

       while [ $c -lt $cword ]; do
                i="${words[c]}"
                case "$i" in
                --)     command="log"; break;;
                -*)     ;;
                *)      command="$i"; break ;;
                esac
                c=$((++c))
        done

breaks, because cword is apparently not defined. and a -lt is no valid syntax.

@Garonenur
Copy link

I don't understand zsh completion enough...

after rm ~/.zcompdump and making sure I really have only the correct completion files in fpath – if I start a new shell and try tig-completion it does not work. If I then use git-completion, which works right of the bat, tig-completion starts to work. So for some reasons, the completion of git is not available to the tig-completion unless I used it.
If you need any more information, I am happy to help.

@rohieb
Copy link

rohieb commented Mar 12, 2020 via email

@koutcher
Copy link
Collaborator

koutcher commented Mar 12, 2020

Try the following patch on /usr/local/share/zsh/site-functions/_tig (or wherever you have it installed):

diff --git a/contrib/tig-completion.zsh b/contrib/tig-completion.zsh
index 585df16..0e5ea12 100644
--- a/contrib/tig-completion.zsh
+++ b/contrib/tig-completion.zsh
@@ -14,6 +14,10 @@

 _tig () {
   local e
+  e=$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
+  if [ -f $e ]; then
+    GIT_SOURCING_ZSH_COMPLETION=y . $e
+  fi
   e=$(dirname ${funcsourcetrace[1]%:*})/tig-completion.bash
   if [ -f $e ]; then
     . $e

@CMGS
Copy link

CMGS commented May 5, 2020

Try the following patch on /usr/local/share/zsh/site-functions/_tig (or wherever you have it installed):

diff --git a/contrib/tig-completion.zsh b/contrib/tig-completion.zsh
index 585df16..0e5ea12 100644
--- a/contrib/tig-completion.zsh
+++ b/contrib/tig-completion.zsh
@@ -14,6 +14,10 @@

 _tig () {
   local e
+  e=$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
+  if [ -f $e ]; then
+    GIT_SOURCING_ZSH_COMPLETION=y . $e
+  fi
   e=$(dirname ${funcsourcetrace[1]%:*})/tig-completion.bash
   if [ -f $e ]; then
     . $e

seems not working either T.T

@koutcher
Copy link
Collaborator

koutcher commented May 5, 2020

Indeed. It did work when I sent it but after a subsequent git upgrade it stopped working. It looks like our zsh completion would need a complete revamp as was done for bash. Unfortunately I'm not using zsh myself so unless some zsh user is volunteering to contribute it our best option will be to remove it and to rely on the basic one provided by zsh.

@kuhmuh
Copy link

kuhmuh commented May 8, 2020

It seems oh my zsh (god bless this tool and its the community 😀) interferes with zsh completion in /usr/local/share/zsh/site-functions/tig-completion.bash or where ever you may have installed it (for me – on mac os – it comes automatically with the installation package of tig). oh my zsh uses compinit to do tab completion. I just removed the links in above directory as

rm /usr/local/share/zsh/site-functions/_tig
rm /usr/local/share/zsh/site-functions/tig-completion.bash

This works at least for me.

@diroussel
Copy link

I got this error when git wasn't installed by brew. Doing "brew install git" fixed it.

primeos added a commit to primeos/nixpkgs that referenced this issue Jul 31, 2020
There are some Nixpkgs specific issues that we could fix but due to
changes in Git it currently isn't possible to source git-completion.bash
from ZSH (at least not how tig-completion.bash expects it).
Upstream issue: jonas/tig#940

For the meantime it seems best to simply not install it anymore so that
the fallback implementation from ZSH can be used (more inaccurate as the
git-log completion is reused but it is helpful to complete remotes,
branches, tags, etc. and doesn't emit an error to the console).
braack pushed a commit to braack/nixpkgs that referenced this issue Oct 29, 2020
There are some Nixpkgs specific issues that we could fix but due to
changes in Git it currently isn't possible to source git-completion.bash
from ZSH (at least not how tig-completion.bash expects it).
Upstream issue: jonas/tig#940

For the meantime it seems best to simply not install it anymore so that
the fallback implementation from ZSH can be used (more inaccurate as the
git-log completion is reused but it is helpful to complete remotes,
branches, tags, etc. and doesn't emit an error to the console).
@felipec
Copy link
Contributor

felipec commented Nov 3, 2020

@Garonenur cword is set by Git completion helpers. In the case of Bash it's the __git_func_wrap function, in the case of Zsh its the _git function.

The idea is that __git_complete git __git_main creates a __git_wrap__git_main function, and that is what Bash uses instead of _git.

However, in Zsh git calls __git_main directly. So in tig it should be called __tig_main.

I sent a pull request with those changes, which includes renaming the main completion function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants