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

compdef: unknown command or service: git #630

Closed
mikebell opened this Issue Sep 26, 2011 · 79 comments

Comments

Projects
None yet
@mikebell

mikebell commented Sep 26, 2011

zsh 4.3.12
lastest clone of oh-my-zsh

After manually installing it (not using the wget method) whenever I login I get a load of code outputted to iterm2.

compdump () {
    # undefined
    builtin autoload -XUz
}
compinit () {
    emulate -L zsh
    setopt extendedglob
    typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1
    typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name
    while [[ $# -gt 0 && $1 = -[dDiuC] ]]
    do
        case "$1" in
            (-d) _i_autodump=1 
                shift
                if [[ $# -gt 0 && "$1" != -[dfQC] ]]
                then
                    _i_dumpfile="$1" 
                    shift
                fi ;;
            (-D) _i_autodump=0 
                shift ;;
            (-i) _i_fail=ign 
                shift ;;
            (-u) _i_fail=use 
                shift ;;
            (-C) _i_check= 
                shift ;;
        esac
    done
    typeset -gA _comps _services _patcomps _postpatcomps
    typeset -gA _compautos
    typeset -gA _lastcomp
    if [[ -n $_i_dumpfile ]]
    then
        typeset -g _comp_dumpfile="$_i_dumpfile"
    else
        typeset -g _comp_dumpfile="${ZDOTDIR:-$HOME}/.zcompdump"
    fi
    typeset -ga _comp_options
    _comp_options=(bareglobqual extendedglob glob multibyte nullglob rcexpandparam unset NO_allexport NO_aliases NO_cshnullglob NO_cshjunkiequotes NO_errexit NO_globsubst NO_histsubstpattern NO_ignorebraces NO_kshglob NO_ksharrays NO_kshtypeset NO_markdirs NO_octalzeroes NO_shwordsplit NO_shglob NO_warncreateglobal) 
    typeset -g _comp_setup='local -A _comp_caller_options;
             _comp_caller_options=(${(kv)options});
             setopt localoptions localtraps ${_comp_options[@]};
             local IFS=$'\'\ \\t\\r\\n\\0\''
             exec </dev/null;
             trap - ZERR
             local -a reply
             local REPLY'
    typeset -ga compprefuncs comppostfuncs
    compprefuncs=() 
    comppostfuncs=() 
    : $funcstack
    compdef () {
        local opt autol type func delete eval new i ret=0 cmd svc
        local -a match mbegin mend
        emulate -L zsh
        setopt extendedglob
        if (( ! $# ))
        then
            print -u2 "$0: I need arguments"
            return 1
        fi
        while getopts "anpPkKde" opt
        do
            case "$opt" in
                (a) autol=yes  ;;
                (n) new=yes  ;;
                ([pPkK]) if [[ -n "$type" ]]
                    then
                        print -u2 "$0: type already set to $type"
                        return 1
                    fi
                    if [[ "$opt" = p ]]
                    then
                        type=pattern 
                    elif [[ "$opt" = P ]]
                    then
                        type=postpattern 
                    elif [[ "$opt" = K ]]
                    then
                        type=widgetkey 
                    else
                        type=key 
                    fi ;;
                (d) delete=yes  ;;
                (e) eval=yes  ;;
            esac
        done
        shift OPTIND-1
        if (( ! $# ))
        then
            print -u2 "$0: I need arguments"
            return 1
        fi
        if [[ -z "$delete" ]]
        then
            if [[ -z "$eval" ]] && [[ "$1" = *\=* ]]
            then
                while (( $# ))
                do
                    if [[ "$1" = *\=* ]]
                    then
                        cmd="${1%%\=*}" 
                        svc="${1#*\=}" 
                        func="$_comps[${_services[(r)$svc]:-$svc}]" 
                        [[ -n ${_services[$svc]} ]] && svc=${_services[$svc]} 
                        [[ -z "$func" ]] && func="${${_patcomps[(K)$svc][1]}:-${_postpatcomps[(K)$svc][1]}}" 
                        if [[ -n "$func" ]]
                        then
                            _comps[$cmd]="$func" 
                            _services[$cmd]="$svc" 
                        else
                            print -u2 "$0: unknown command or service: $svc"
                            ret=1 
                        fi
                    else
                        print -u2 "$0: invalid argument: $1"
                        ret=1 
                    fi
                    shift
                done
                return ret
            fi
            func="$1" 
            [[ -n "$autol" ]] && autoload -Uz "$func"
            shift
            case "$type" in
                (widgetkey) while [[ -n $1 ]]
                    do
                        if [[ $# -lt 3 ]]
                        then
                            print -u2 "$0: compdef -K requires <widget> <comp-widget> <key>"
                            return 1
                        fi
                        [[ $1 = _* ]] || 1="_$1" 
                        [[ $2 = .* ]] || 2=".$2" 
                        [[ $2 = .menu-select ]] && zmodload -i zsh/complist
                        zle -C "$1" "$2" "$func"
                        if [[ -n $new ]]
                        then
                            bindkey "$3" | read -A opt
                            [[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1"
                        else
                            bindkey "$3" "$1"
                        fi
                        shift 3
                    done ;;
                (key) if [[ $# -lt 2 ]]
                    then
                        print -u2 "$0: missing keys"
                        return 1
                    fi
                    if [[ $1 = .* ]]
                    then
                        [[ $1 = .menu-select ]] && zmodload -i zsh/complist
                        zle -C "$func" "$1" "$func"
                    else
                        [[ $1 = menu-select ]] && zmodload -i zsh/complist
                        zle -C "$func" ".$1" "$func"
                    fi
                    shift
                    for i
                    do
                        if [[ -n $new ]]
                        then
                            bindkey "$i" | read -A opt
                            [[ $opt[-1] = undefined-key ]] || continue
                        fi
                        bindkey "$i" "$func"
                    done ;;
                (*) while (( $# ))
                    do
                        if [[ "$1" = -N ]]
                        then
                            type=normal 
                        elif [[ "$1" = -p ]]
                        then
                            type=pattern 
                        elif [[ "$1" = -P ]]
                        then
                            type=postpattern 
                        else
                            case "$type" in
                                (pattern) if [[ $1 = (#b)(*)=(*) ]]
                                    then
                                        _patcomps[$match[1]]="=$match[2]=$func" 
                                    else
                                        _patcomps[$1]="$func" 
                                    fi ;;
                                (postpattern) if [[ $1 = (#b)(*)=(*) ]]
                                    then
                                        _postpatcomps[$match[1]]="=$match[2]=$func" 
                                    else
                                        _postpatcomps[$1]="$func" 
                                    fi ;;
                                (*) if [[ "$1" = *\=* ]]
                                    then
                                        cmd="${1%%\=*}" 
                                        svc=yes 
                                    else
                                        cmd="$1" 
                                        svc= 
                                    fi
                                    if [[ -z "$new" || -z "${_comps[$1]}" ]]
                                    then
                                        _comps[$cmd]="$func" 
                                        [[ -n "$svc" ]] && _services[$cmd]="${1#*\=}" 
                                    fi ;;
                            esac
                        fi
                        shift
                    done ;;
            esac
        else
            case "$type" in
                (pattern) unset "_patcomps[$^@]" ;;
                (postpattern) unset "_postpatcomps[$^@]" ;;
                (key) print -u2 "$0: cannot restore key bindings"
                    return 1 ;;
                (*) unset "_comps[$^@]" ;;
            esac
        fi
    }
    typeset _i_wdirs _i_wfiles
    _i_wdirs=() 
    _i_wfiles=() 
    autoload -Uz compaudit
    if [[ -n "$_i_check" ]]
    then
        typeset _i_q
        if ! eval compaudit
        then
            if [[ -n "$_i_q" ]]
            then
                if [[ "$_i_fail" = ask ]]
                then
                    if ! read -q "?zsh compinit: insecure $_i_q, run compaudit for list.
Ignore insecure $_i_q and continue [y] or abort compinit [n]? "
                    then
                        print -u2 "$0: initialization aborted"
                        unfunction compinit compdef
                        unset _comp_dumpfile _comp_secure compprefuncs comppostfuncs _comps _patcomps _postpatcomps _compautos _lastcomp
                        return 1
                    fi
                    _i_wfiles=() 
                    _i_wdirs=() 
                else
                    (( $#_i_wfiles )) && _i_files=("${(@)_i_files:#(${(j:|:)_i_wfiles%.zwc})}") 
                    (( $#_i_wdirs )) && _i_files=("${(@)_i_files:#(${(j:|:)_i_wdirs%.zwc})/*}") 
                fi
            fi
            typeset -g _comp_secure=yes
        fi
    fi
    autoload -Uz compdump compinstall
    _i_done='' 
    if [[ -f "$_comp_dumpfile" ]]
    then
        if [[ -n "$_i_check" ]]
        then
            read -rA _i_line < "$_comp_dumpfile"
            if [[ _i_autodump -eq 1 && $_i_line[2] -eq $#_i_files && $ZSH_VERSION = $_i_line[4] ]]
            then
                builtin . "$_comp_dumpfile"
                _i_done=yes 
            fi
        else
            builtin . "$_comp_dumpfile"
            _i_done=yes 
        fi
    fi
    if [[ -z "$_i_done" ]]
    then
        typeset -A _i_test
        for _i_dir in $fpath
        do
            [[ $_i_dir = . ]] && continue
            (( $_i_wdirs[(I)$_i_dir] )) && continue
            for _i_file in $_i_dir/^([^_]*|*~|*.zwc)(N)
            do
                _i_name="${_i_file:t}" 
                (( $+_i_test[$_i_name] + $_i_wfiles[(I)$_i_file] )) && continue
                _i_test[$_i_name]=yes 
                read -rA _i_line < $_i_file
                _i_tag=$_i_line[1] 
                shift _i_line
                case $_i_tag in
                    (\#compdef) if [[ $_i_line[1] = -[pPkK](n|) ]]
                        then
                            compdef ${_i_line[1]}na "${_i_name}" "${(@)_i_line[2,-1]}"
                        else
                            compdef -na "${_i_name}" "${_i_line[@]}"
                        fi ;;
                    (\#autoload) autoload -Uz "$_i_line[@]" ${_i_name}
                        [[ "$_i_line" != \ # ]] && _compautos[${_i_name}]="$_i_line"  ;;
                esac
            done
        done
        if [[ $_i_autodump = 1 ]]
        then
            compdump
        fi
    fi
    for _i_line in complete-word delete-char-or-list expand-or-complete expand-or-complete-prefix list-choices menu-complete menu-expand-or-complete reverse-menu-complete
    do
        zle -C $_i_line .$_i_line _main_complete
    done
    zle -la menu-select && zle -C menu-select .menu-select _main_complete
    bindkey '^i' | read -A _i_line
    if [[ ${_i_line[2]} = expand-or-complete ]] && zstyle -a ':completion:' completer _i_line && (( ${_i_line[(i)_expand]} <= ${#_i_line} ))
    then
        bindkey '^i' complete-word
    fi
    unfunction compinit compaudit
    autoload -Uz compinit compaudit
    return 0
}
compinstall () {
    # undefined
    builtin autoload -XUz
}
edit-command-line () {
    # undefined
    builtin autoload -XU
}
url-quote-magic () {
    # undefined
    builtin autoload -XU
}
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git

Tab complete doesn't work, the git plugin seems to be working and themes are also working. This is my 5th install of oh-my-zsh and I've not seen this issue before.

@gwjo

This comment has been minimized.

Show comment
Hide comment
@gwjo

gwjo Sep 28, 2011

Contributor

The compdef error is the same one as in #399, but that was caused by an older version of zsh that didn't have the git completions.

Contributor

gwjo commented Sep 28, 2011

The compdef error is the same one as in #399, but that was caused by an older version of zsh that didn't have the git completions.

@BigForNothing

This comment has been minimized.

Show comment
Hide comment
@BigForNothing

BigForNothing Oct 17, 2011

Try running this and see if it fixes it for you:

compaudit | xargs chmod g-w

It did for me.

BigForNothing commented Oct 17, 2011

Try running this and see if it fixes it for you:

compaudit | xargs chmod g-w

It did for me.

@theckman

This comment has been minimized.

Show comment
Hide comment
@theckman

theckman Nov 26, 2011

I'm having the same issue as well. The above recommendation had no change as compaudit did not print out any lines.

Any other theories?

theckman commented Nov 26, 2011

I'm having the same issue as well. The above recommendation had no change as compaudit did not print out any lines.

Any other theories?

@theckman

This comment has been minimized.

Show comment
Hide comment
@theckman

theckman Nov 28, 2011

Here's a bit more info about the system I am currently using:

Mac OS X 10.5.8
zsh 4.3.4 (i386-apple-darwin9.0)
iTerm2 Build 1.0.0.20111020

theckman commented Nov 28, 2011

Here's a bit more info about the system I am currently using:

Mac OS X 10.5.8
zsh 4.3.4 (i386-apple-darwin9.0)
iTerm2 Build 1.0.0.20111020

@borisbrodski

This comment has been minimized.

Show comment
Hide comment
@borisbrodski

borisbrodski Jan 5, 2012

Confirm that on N900 Maemo:

$ uname -a
Linux Nokia-N900 2.6.28.10-power49 #1 PREEMPT Fri Nov 18 23:59:53 EET 2011 armv7l unknown

$ zsh -v
zsh 4.3.10 (arm-unknown-linux-gnu)

borisbrodski commented Jan 5, 2012

Confirm that on N900 Maemo:

$ uname -a
Linux Nokia-N900 2.6.28.10-power49 #1 PREEMPT Fri Nov 18 23:59:53 EET 2011 armv7l unknown

$ zsh -v
zsh 4.3.10 (arm-unknown-linux-gnu)

@theckman

This comment has been minimized.

Show comment
Hide comment
@theckman

theckman Jan 5, 2012

I figured out the problem I was experiencing. I had installed zsh view homebrew on OS X. In the process of moving to ZSH I didn't realize my path got whacked out and it was using the Apple-supplied version of ZSH and not the one I had built.

Fix path, re-chsh, happiness ensued.

theckman commented Jan 5, 2012

I figured out the problem I was experiencing. I had installed zsh view homebrew on OS X. In the process of moving to ZSH I didn't realize my path got whacked out and it was using the Apple-supplied version of ZSH and not the one I had built.

Fix path, re-chsh, happiness ensued.

@gdelfino

This comment has been minimized.

Show comment
Hide comment
@gdelfino

gdelfino Feb 8, 2012

I am having these same issue. I am using zsh 4.3.15 installed in /usr/local/bin/zsh and git 1.7.3.2

This is on a Centos 5.7 machine and the problem happens with regular users but not with the root user.

Curiously I have an identical install on a Centos 6 machine that worked just fine.

gdelfino commented Feb 8, 2012

I am having these same issue. I am using zsh 4.3.15 installed in /usr/local/bin/zsh and git 1.7.3.2

This is on a Centos 5.7 machine and the problem happens with regular users but not with the root user.

Curiously I have an identical install on a Centos 6 machine that worked just fine.

@theckman

This comment has been minimized.

Show comment
Hide comment
@theckman

theckman Feb 8, 2012

You can't really call two similar CentOS 5.7 and 6.X installs identical. Also, are you sure that your non-root users are using the zsh 4.3.15 installed in /usr/local/bin/zsh? There are three commands you can run to verify:

echo $SHELL
which zsh
zsh --version

I had an issue where I thought I had the right version installed, but the way my paths where I was using the system installed version of ZSH, and not the one I had installed.

theckman commented Feb 8, 2012

You can't really call two similar CentOS 5.7 and 6.X installs identical. Also, are you sure that your non-root users are using the zsh 4.3.15 installed in /usr/local/bin/zsh? There are three commands you can run to verify:

echo $SHELL
which zsh
zsh --version

I had an issue where I thought I had the right version installed, but the way my paths where I was using the system installed version of ZSH, and not the one I had installed.

@wishi

This comment has been minimized.

Show comment
Hide comment
@wishi

wishi Feb 16, 2012

I have the same problem with Arch Linux
zsh 4.3.15

compaudit | xargs chmod g-w
zsh: command not found: compaudit
chmod: missing operand after `g-w'

wishi commented Feb 16, 2012

I have the same problem with Arch Linux
zsh 4.3.15

compaudit | xargs chmod g-w
zsh: command not found: compaudit
chmod: missing operand after `g-w'

@j16r

This comment has been minimized.

Show comment
Hide comment
@j16r

j16r Apr 10, 2012

Contributor

I'm seeing this problem also, when running up to date zsh:

zsh 4.3.17 (x86_64-apple-darwin11.3.0)
Darwin ix.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
Contributor

j16r commented Apr 10, 2012

I'm seeing this problem also, when running up to date zsh:

zsh 4.3.17 (x86_64-apple-darwin11.3.0)
Darwin ix.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
@theckman

This comment has been minimized.

Show comment
Hide comment
@theckman

theckman Apr 10, 2012

@excepttheweasel what does echo $SHELL give you? What version do you get when running that executable?

theckman commented Apr 10, 2012

@excepttheweasel what does echo $SHELL give you? What version do you get when running that executable?

@j16r

This comment has been minimized.

Show comment
Hide comment
@j16r

j16r Apr 10, 2012

Contributor

echo $SHELL =>

/usr/local/bin/zsh

Which is version 4.3.17 as posted above, provided by homebrew.

Contributor

j16r commented Apr 10, 2012

echo $SHELL =>

/usr/local/bin/zsh

Which is version 4.3.17 as posted above, provided by homebrew.

@theckman

This comment has been minimized.

Show comment
Hide comment
@theckman

theckman Apr 10, 2012

Seems we are running identical configurations. Mine just seemed to work out of the box when I set up homebrew and oh-my-zsh on my Air.

theckman commented Apr 10, 2012

Seems we are running identical configurations. Mine just seemed to work out of the box when I set up homebrew and oh-my-zsh on my Air.

@funnell

This comment has been minimized.

Show comment
Hide comment
@funnell

funnell Oct 10, 2012

I'm also having this problem on one of the linux servers I'm using. It works on a different linux server and two different Apple computers. I'm also using the version that I compiled (5.0.0).

funnell commented Oct 10, 2012

I'm also having this problem on one of the linux servers I'm using. It works on a different linux server and two different Apple computers. I'm also using the version that I compiled (5.0.0).

@funnell

This comment has been minimized.

Show comment
Hide comment
@funnell

funnell Oct 10, 2012

The code being outputted seems to come from this line:
compinit -i

This thread is relevant:
http://www.zsh.org/mla/users/2007/msg00722.html

Specifically the last email in that thread that suggests deleting .zcompdump seemed to work for me. I'm not sure if it's related, but I did change my locale from something like latin9 to en_CA.utf-8 before doing this.

funnell commented Oct 10, 2012

The code being outputted seems to come from this line:
compinit -i

This thread is relevant:
http://www.zsh.org/mla/users/2007/msg00722.html

Specifically the last email in that thread that suggests deleting .zcompdump seemed to work for me. I'm not sure if it's related, but I did change my locale from something like latin9 to en_CA.utf-8 before doing this.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 6, 2012

am having something similar.
zsh 5.0.0 (x86_64-apple-darwin11.4.0)
oh-myzsh (latest update)
enabled git plugin

I get an error Error: compdef: unknown command or service: git
autocompletion seems to be disabled
When i disable git plugin the error disappears but autocompletion is still off

compaudit | xargs chmod g-w does not fix the issue
Any ideas?

ghost commented Dec 6, 2012

am having something similar.
zsh 5.0.0 (x86_64-apple-darwin11.4.0)
oh-myzsh (latest update)
enabled git plugin

I get an error Error: compdef: unknown command or service: git
autocompletion seems to be disabled
When i disable git plugin the error disappears but autocompletion is still off

compaudit | xargs chmod g-w does not fix the issue
Any ideas?

@ikari-pl

This comment has been minimized.

Show comment
Hide comment
@ikari-pl

ikari-pl Dec 7, 2012

And the same for me.

➜ ~ zsh --version 2012-12-07 11:04:51 CET zsh --version zsh 4.3.12 (i686-pc-cygwin)

pulled oh-my-zsh a minute ago just to be sure.

ikari-pl commented Dec 7, 2012

And the same for me.

➜ ~ zsh --version 2012-12-07 11:04:51 CET zsh --version zsh 4.3.12 (i686-pc-cygwin)

pulled oh-my-zsh a minute ago just to be sure.

@tomek

This comment has been minimized.

Show comment
Hide comment
@tomek

tomek Dec 7, 2012

Contributor

When I had similar issue with oh-my-zsh + zsh on cygwin I used this rm -f ~/.zcompdump; compinit and everything started to work again, tho I don't know if it will help in your case.

Contributor

tomek commented Dec 7, 2012

When I had similar issue with oh-my-zsh + zsh on cygwin I used this rm -f ~/.zcompdump; compinit and everything started to work again, tho I don't know if it will help in your case.

@ikari-pl

This comment has been minimized.

Show comment
Hide comment
@ikari-pl

ikari-pl Dec 8, 2012

I could swear I already did that twice. Somehow, now it helped.

ikari-pl commented Dec 8, 2012

I could swear I already did that twice. Somehow, now it helped.

@mmlindeboom

This comment has been minimized.

Show comment
Hide comment
@mmlindeboom

mmlindeboom Feb 7, 2013

I had a similar issue. I was running OSX 10.5.8. I upgraded to 10.6.3 and I no longer receive any "compdef: unknown command or service: git" errors.

mmlindeboom commented Feb 7, 2013

I had a similar issue. I was running OSX 10.5.8. I upgraded to 10.6.3 and I no longer receive any "compdef: unknown command or service: git" errors.

@douglascamata

This comment has been minimized.

Show comment
Hide comment
@douglascamata

douglascamata Feb 19, 2013

@Eustachy instructions worked fine for me.

douglascamata commented Feb 19, 2013

@Eustachy instructions worked fine for me.

@Esop

This comment has been minimized.

Show comment
Hide comment
@Esop

Esop Mar 5, 2013

"rm -f ~/.zcompdump; compinit" fixed my issues.

Esop commented Mar 5, 2013

"rm -f ~/.zcompdump; compinit" fixed my issues.

@amiorin

This comment has been minimized.

Show comment
Hide comment
@amiorin

amiorin May 27, 2013

I had this problem with sudo -s

I fixed with :

compaudit | xargs chmod g-w
compaudit | xargs chown root

amiorin commented May 27, 2013

I had this problem with sudo -s

I fixed with :

compaudit | xargs chmod g-w
compaudit | xargs chown root
@ranjanashish

This comment has been minimized.

Show comment
Hide comment
@ranjanashish

ranjanashish Jul 1, 2013

@Eustachy rm -f ~/.zcompdump; compinit worked like a charm.
Thanks a lot. 👍

ranjanashish commented Jul 1, 2013

@Eustachy rm -f ~/.zcompdump; compinit worked like a charm.
Thanks a lot. 👍

@icecreammatt

This comment has been minimized.

Show comment
Hide comment
@icecreammatt

icecreammatt Jul 18, 2013

@Eustachy Thanks a bunch! 🍰

icecreammatt commented Jul 18, 2013

@Eustachy Thanks a bunch! 🍰

@huubby

This comment has been minimized.

Show comment
Hide comment
@huubby

huubby Jul 25, 2013

@Eustachy rm -f ~/.zcompdump; compinit works, thanks!

huubby commented Jul 25, 2013

@Eustachy rm -f ~/.zcompdump; compinit works, thanks!

@Morthor

This comment has been minimized.

Show comment
Hide comment
@Morthor

Morthor commented Aug 5, 2013

@Eustachy Thank you!

@RohitRox

This comment has been minimized.

Show comment
Hide comment
@RohitRox

RohitRox Aug 21, 2013

compaudit | xargs chmod g-w worked for me in Lion 👍

RohitRox commented Aug 21, 2013

compaudit | xargs chmod g-w worked for me in Lion 👍

@fhoshino

This comment has been minimized.

Show comment
Hide comment
@fhoshino

fhoshino Sep 21, 2013

rm -f ~/.zcompdump; compinit failed recent update on cygwin, any help?

fhoshino commented Sep 21, 2013

rm -f ~/.zcompdump; compinit failed recent update on cygwin, any help?

@nnadboralski-zz

This comment has been minimized.

Show comment
Hide comment
@nnadboralski-zz

nnadboralski-zz Oct 13, 2013

On Mac OS X 10.8.5 with zsh 5.0.2 I encountered the error

compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git

I solved it by combining the suggestions in this thread, but, all steps were required. I was able to reproduce the situation in which it occured multiple times and test each time. Specifically the issue is introduced for me by switching from the zsh included with mac os x to 5.0.2.

compaudit | sudo xargs chmod g-w
compaudit | sudo xargs chown root
rm ~/.zcompdump*
compinit

nnadboralski-zz commented Oct 13, 2013

On Mac OS X 10.8.5 with zsh 5.0.2 I encountered the error

compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git
compdef: unknown command or service: git

I solved it by combining the suggestions in this thread, but, all steps were required. I was able to reproduce the situation in which it occured multiple times and test each time. Specifically the issue is introduced for me by switching from the zsh included with mac os x to 5.0.2.

compaudit | sudo xargs chmod g-w
compaudit | sudo xargs chown root
rm ~/.zcompdump*
compinit
@Morthor

This comment has been minimized.

Show comment
Hide comment
@Morthor

Morthor Oct 14, 2013

@nnadboralski You sir, are a life saver.
Thank you very much for taking the time to put your solution here.

Morthor commented Oct 14, 2013

@nnadboralski You sir, are a life saver.
Thank you very much for taking the time to put your solution here.

@fhoshino

This comment has been minimized.

Show comment
Hide comment
@fhoshino

fhoshino Oct 16, 2013

@nnadboralski You saved my day!
I added these lines to my zshrc.

fhoshino commented Oct 16, 2013

@nnadboralski You saved my day!
I added these lines to my zshrc.

@bcbcarl

This comment has been minimized.

Show comment
Hide comment
@bcbcarl

bcbcarl Nov 5, 2013

@nnadboralski Great! It works!

bcbcarl commented Nov 5, 2013

@nnadboralski Great! It works!

@jitendravyas

This comment has been minimized.

Show comment
Hide comment
@jitendravyas

jitendravyas Nov 7, 2013

@fhoshino same for me

@robbyrussell when i run this in cygwin it asks this question.

➜ ~ rm -f ~/.zcompdump; compinit
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?

jitendravyas commented Nov 7, 2013

@fhoshino same for me

@robbyrussell when i run this in cygwin it asks this question.

➜ ~ rm -f ~/.zcompdump; compinit
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?

@twilek

This comment has been minimized.

Show comment
Hide comment
@twilek

twilek Nov 9, 2013

I get this issue in Cygwin 64bit on a Windows 8 machine, but do not get it when I do the same install on a Windows 7 machine which is a bit strage. Non of the fixes above works for me. I also get the same question as @jitendravyas

twilek commented Nov 9, 2013

I get this issue in Cygwin 64bit on a Windows 8 machine, but do not get it when I do the same install on a Windows 7 machine which is a bit strage. Non of the fixes above works for me. I also get the same question as @jitendravyas

@twilek

This comment has been minimized.

Show comment
Hide comment
@twilek

twilek Nov 9, 2013

I now noticed that .zcompdump was named .zcompdump-modhelius-dell-5.0.2 and this file was almost empty. After running compinit I noticed that a file only named .zcompdump was created, taking the content of this file and copying it into .zcompdump-modhelius-dell-5.0.2 fixed the problem for me.

twilek commented Nov 9, 2013

I now noticed that .zcompdump was named .zcompdump-modhelius-dell-5.0.2 and this file was almost empty. After running compinit I noticed that a file only named .zcompdump was created, taking the content of this file and copying it into .zcompdump-modhelius-dell-5.0.2 fixed the problem for me.

@jitendravyas

This comment has been minimized.

Show comment
Hide comment
@jitendravyas

jitendravyas Nov 9, 2013

@twilek Thanks. it fixed the problem now

jitendravyas commented Nov 9, 2013

@twilek Thanks. it fixed the problem now

@lcorsini

This comment has been minimized.

Show comment
Hide comment
@lcorsini

lcorsini Mar 25, 2015

I had a similar problem with babun on windows 7, using tmux gave me that error.
I solved changing this:
in .oh-my-zsh/oh-my-zsh.sh

# Save the location of the current completion dump file.
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
# to:
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump"

I don't know the implications of this mod, but it seems to work now

lcorsini commented Mar 25, 2015

I had a similar problem with babun on windows 7, using tmux gave me that error.
I solved changing this:
in .oh-my-zsh/oh-my-zsh.sh

# Save the location of the current completion dump file.
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
# to:
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump"

I don't know the implications of this mod, but it seems to work now

@Eduruiz

This comment has been minimized.

Show comment
Hide comment
@Eduruiz

Eduruiz Apr 24, 2015

rm -f ~/.zcompdump; compinit did the trick here too. thanks!!

Eduruiz commented Apr 24, 2015

rm -f ~/.zcompdump; compinit did the trick here too. thanks!!

leycec added a commit to leycec/oh-my-zsh that referenced this issue May 12, 2015

Repair Cygwin zsh path permissions on startup.
Cygwin installs top-level zsh directories (e.g., "/usr/share/zsh") with
insecure permissions allowing group writability. Since compinit()
always ignores these directories, oh-my-zsh creates an effectively empty
".zcompdump" file on startup, resulting in obscure compdef() errors such
as "compdef: unknown command or service: git".

oh-my-zsh now detects and reports these insecurities under all platforms
including Cygwin. Under Cygwin, it also offers to repair these
insecurities, fixing #630 as well as babun issues 159, 281, and 322.

leycec added a commit to leycec/oh-my-zsh that referenced this issue May 13, 2015

Repair Cygwin zsh path permissions on startup.
Cygwin installs top-level zsh directories (e.g., "/usr/share/zsh") with
insecure permissions allowing group writability. Since compinit()
always ignores these directories, oh-my-zsh creates an effectively empty
".zcompdump" file on startup, resulting in obscure compdef() errors such
as "compdef: unknown command or service: git".

oh-my-zsh now detects and reports these insecurities under all platforms
including Cygwin and, under Cygwin, offers to repair them. This fixes
issue #630 under Cygwin and the related babun issues 159, 281, and 322.
@leycec

This comment has been minimized.

Show comment
Hide comment
@leycec

leycec May 13, 2015

Contributor

In the time-honoured open-source tradition of "If you want a bug murdered, pick up the hatchet yourself.", I've submitted a pull request that:

  • Fixes the bulk of these issues under Cygwin.
  • Significantly improves startup error reporting (although not quite fixing these issues) under non-Cygwin platforms. This means OS X and Linux, primarily.

And the Octopus saw it, and it was good. 🐙

Contributor

leycec commented May 13, 2015

In the time-honoured open-source tradition of "If you want a bug murdered, pick up the hatchet yourself.", I've submitted a pull request that:

  • Fixes the bulk of these issues under Cygwin.
  • Significantly improves startup error reporting (although not quite fixing these issues) under non-Cygwin platforms. This means OS X and Linux, primarily.

And the Octopus saw it, and it was good. 🐙

@DoubleDensity

This comment has been minimized.

Show comment
Hide comment
@DoubleDensity

DoubleDensity Jul 7, 2015

I am still seeing this issue on MacOS 10.10.3, anyone else? I tried all of the fixes listed above, but every time I start a new shell I get:

compdef: unknown command or service: git
compdef: unknown command or service: git

zsh 5.0.7 (x86_64-apple-darwin14.0.0)

I cloned oh-my-zsh this morning and currently have this revision:

3ea3384

Update

Not sure how it is possible, but switching to zsh 5.0.8 (x86_64-apple-darwin14.3.0) from Brew seemed to fix it!

DoubleDensity commented Jul 7, 2015

I am still seeing this issue on MacOS 10.10.3, anyone else? I tried all of the fixes listed above, but every time I start a new shell I get:

compdef: unknown command or service: git
compdef: unknown command or service: git

zsh 5.0.7 (x86_64-apple-darwin14.0.0)

I cloned oh-my-zsh this morning and currently have this revision:

3ea3384

Update

Not sure how it is possible, but switching to zsh 5.0.8 (x86_64-apple-darwin14.3.0) from Brew seemed to fix it!

@bradleyflood

This comment has been minimized.

Show comment
Hide comment
@bradleyflood

bradleyflood Jul 10, 2015

Temporarily fixed by @tomek's solution rm -f ~/.zcompdump; compinit this temporarily fixes the launch errors, git errors, and no autocompletion issues for me, BUT, they return on next time I open shell.

I'm on a Mac, never used zsh before, only just installed oh-my-zsh and ran into these issues. No changes to any settings from default.

sw_vers
ProductName:    Mac OS X
ProductVersion: 10.10.4
BuildVersion:   14E46
which zsh
/usr/local/bin/zsh
zsh --version
zsh 5.0.6 (x86_64-apple-darwin14.0.0)

UPDATE
After completely and thoroughly removing zsh, oh-my-zsh, and homebrew, chown -R $USER /Library/ and Brew directories to me, then reinstalling all afresh, NOW my autocomplete is working and the large dump of errors/config is gone, BUT, I've still got the compdef: unknown command or service: git errors, even after trying above solutions the errors return on each new terminal window.

bradleyflood commented Jul 10, 2015

Temporarily fixed by @tomek's solution rm -f ~/.zcompdump; compinit this temporarily fixes the launch errors, git errors, and no autocompletion issues for me, BUT, they return on next time I open shell.

I'm on a Mac, never used zsh before, only just installed oh-my-zsh and ran into these issues. No changes to any settings from default.

sw_vers
ProductName:    Mac OS X
ProductVersion: 10.10.4
BuildVersion:   14E46
which zsh
/usr/local/bin/zsh
zsh --version
zsh 5.0.6 (x86_64-apple-darwin14.0.0)

UPDATE
After completely and thoroughly removing zsh, oh-my-zsh, and homebrew, chown -R $USER /Library/ and Brew directories to me, then reinstalling all afresh, NOW my autocomplete is working and the large dump of errors/config is gone, BUT, I've still got the compdef: unknown command or service: git errors, even after trying above solutions the errors return on each new terminal window.

leycec added a commit to leycec/oh-my-zsh that referenced this issue Jul 11, 2015

Handle completion insecurities on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.

leycec added a commit to leycec/oh-my-zsh that referenced this issue Jul 11, 2015

Handle completion insecurities on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.
@zxkane

This comment has been minimized.

Show comment
Hide comment
@zxkane

zxkane Jul 12, 2015

I met this issue after migrating data from old Air to a new Pro via migration assistant.

Fixed the issue after running below commands from one of above comments.

compaudit | sudo xargs chmod g-w
compaudit | sudo xargs chown root
rm ~/.zcompdump*
compinit

zxkane commented Jul 12, 2015

I met this issue after migrating data from old Air to a new Pro via migration assistant.

Fixed the issue after running below commands from one of above comments.

compaudit | sudo xargs chmod g-w
compaudit | sudo xargs chown root
rm ~/.zcompdump*
compinit

leycec added a commit to leycec/oh-my-zsh that referenced this issue Jul 20, 2015

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.

kirb added a commit to kirb/oh-my-zsh that referenced this issue Oct 3, 2015

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.

Spirotot added a commit to Spirotot/oh-my-zsh that referenced this issue Oct 21, 2015

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.
@GrezL

This comment has been minimized.

Show comment
Hide comment
@GrezL

GrezL Oct 29, 2015

I just comment

plugins=(git)

in .zshrc and fix it

GrezL commented Oct 29, 2015

I just comment

plugins=(git)

in .zshrc and fix it

@xiaji

This comment has been minimized.

Show comment
Hide comment
@xiaji

xiaji Nov 18, 2015

@zxkane It works for me. but I need login as a root to fix this problem.

xiaji commented Nov 18, 2015

@zxkane It works for me. but I need login as a root to fix this problem.

@emolr

This comment has been minimized.

Show comment
Hide comment
@emolr

emolr Dec 4, 2015

@BigForNothing Thanks for the snippet, it worked for me 👍

emolr commented Dec 4, 2015

@BigForNothing Thanks for the snippet, it worked for me 👍

@pfdai

This comment has been minimized.

Show comment
Hide comment
@pfdai

pfdai Dec 7, 2015

Just for the record - adding gitfast fixed this issue for me

plugins=(git gitfast)

pfdai commented Dec 7, 2015

Just for the record - adding gitfast fixed this issue for me

plugins=(git gitfast)

@rob-heine

This comment has been minimized.

Show comment
Hide comment
@rob-heine

rob-heine Dec 14, 2015

Thanks, @pfdai. Worked like a charm, running with plugins=(git gitfast mvn zsh-syntax-highlighting) now. 👍

rob-heine commented Dec 14, 2015

Thanks, @pfdai. Worked like a charm, running with plugins=(git gitfast mvn zsh-syntax-highlighting) now. 👍

@dijonkitchen

This comment has been minimized.

Show comment
Hide comment
@dijonkitchen

dijonkitchen Dec 21, 2015

Thanks @pfdai ! Adding gitfast did it for me too! None of the other things worked for me!

dijonkitchen commented Dec 21, 2015

Thanks @pfdai ! Adding gitfast did it for me too! None of the other things worked for me!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 31, 2015

@pfdai Thanks a lot!

ghost commented Dec 31, 2015

@pfdai Thanks a lot!

FrankSansC pushed a commit to FrankSansC/oh-my-zsh that referenced this issue Jan 5, 2016

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.
@Siafu

This comment has been minimized.

Show comment
Hide comment
@Siafu

Siafu Apr 16, 2016

I get

 compinit:496: no such file or directory: /usr/local/share/zsh/site-functions/_git
compinit:shift:498: shift count must be <= $#
compinit:496: no such file or directory: /usr/local/share/zsh/site-functions/_j
compinit:shift:498: shift count must be <= $# 

when i do compinit

Siafu commented Apr 16, 2016

I get

 compinit:496: no such file or directory: /usr/local/share/zsh/site-functions/_git
compinit:shift:498: shift count must be <= $#
compinit:496: no such file or directory: /usr/local/share/zsh/site-functions/_j
compinit:shift:498: shift count must be <= $# 

when i do compinit

@NSMyself

This comment has been minimized.

Show comment
Hide comment
@NSMyself

NSMyself commented Apr 17, 2016

Same.

NobbZ added a commit to NobbZ/oh-my-zsh that referenced this issue May 15, 2016

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.

gaboesquivel added a commit to gaboesquivel/oh-my-zsh that referenced this issue Sep 7, 2016

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.

DennisDenuto added a commit to DennisDenuto/oh-my-zsh that referenced this issue Oct 29, 2016

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.

ericlake pushed a commit to ericlake/oh-my-zsh that referenced this issue Feb 13, 2017

fforw added a commit to fforw/oh-my-zsh that referenced this issue Feb 21, 2017

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.
@aryehbeitz

This comment has been minimized.

Show comment
Hide comment
@aryehbeitz

aryehbeitz Feb 28, 2018

I ran zsh -xv &> >(tee ~/omz-debug.log 2>/dev/null) and searched for the text of the errors I received

For this error:

complete:13: command not found: compdef

I fixed it in the file ~/.nvm/bash_completion on line 96, i commented out this line
complete -o default -F __nvm nvm

For this error:

__rvm_cleanse_variables: function definition file not found
command not found: rvm_error

I had to comment out a few lines around .rvm/scripts/initialize

__rvm_cleanse_variables ||
if [[ -n "${ZSH_VERSION:-}" ]]
then rvm_error "ZSH Error, run \`rm -f ~/.zcompdump\` and try again."
fi

aryehbeitz commented Feb 28, 2018

I ran zsh -xv &> >(tee ~/omz-debug.log 2>/dev/null) and searched for the text of the errors I received

For this error:

complete:13: command not found: compdef

I fixed it in the file ~/.nvm/bash_completion on line 96, i commented out this line
complete -o default -F __nvm nvm

For this error:

__rvm_cleanse_variables: function definition file not found
command not found: rvm_error

I had to comment out a few lines around .rvm/scripts/initialize

__rvm_cleanse_variables ||
if [[ -n "${ZSH_VERSION:-}" ]]
then rvm_error "ZSH Error, run \`rm -f ~/.zcompdump\` and try again."
fi

kingbin added a commit to kingbin/oh-my-zsh that referenced this issue Mar 12, 2018

Completion insecurities handled on startup.
Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.
@278kunal

This comment has been minimized.

Show comment
Hide comment
@278kunal

278kunal May 6, 2018

@nnadboralski-zz Thanks Bro !! You made my day.

278kunal commented May 6, 2018

@nnadboralski-zz Thanks Bro !! You made my day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment