fzf-tab icon indicating copy to clipboard operation
fzf-tab copied to clipboard

_ftb__main_complete command not found

Open fjchen7 opened this issue 6 months ago • 5 comments

Describe the bug

A clear and concise description of what the bug is.

I can make sure:

  • [x] I am using the latest version of fzf-tab
  • [x] this is the minimal zshrc which can reproduce this bug
  • [x] fzf-tab is loaded after compinit
  • [x] fzf-tab is loaded after plugins which will wrap Tab, like junegunn/fzf/completion.zsh
  • [x] fzf-tab is loaded before zsh-autosuggestions, zsh-syntax-highlighting and fast-syntax-highlighting.

To Reproduce

Steps to reproduce the behavior:

  1. Type 'cd'
  2. Press Tab
  3. See error

Expected behavior

Show completion memu.

Screenshots

Image

However sometimes it show permission denied

Image

Environment:

  • OS: macOS 15.5
  • zsh version: zsh 5.9 (arm-apple-darwin24.2.0) (/opt/homebrew/bin/zsh)
  • zimfw: 1.18.0

Minimal zshrc

.zshrc

# -----------
#  Zim setup
# -----------
# Set directory where Zim will be installed
ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
# Download zimfw plugin manager if missing.
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
  curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
      https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
fi
# Install missing modules and update ${ZIM_HOME}/init.zsh if missing or outdated.
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} ]]; then
  source ${ZIM_HOME}/zimfw.zsh init
fi
# Initialize modules.
source ${ZIM_HOME}/init.zsh

.zimrc

# Use degit instead of git submodules for faster cloning
zstyle ':zim:zmodule' use 'degit'
zstyle ':zim:completion' dumpfile "${XDG_CACHE_HOME:-$HOME/.cache}/zsh/.zcompdump"

zmodule environment
zmodule input

zmodule zsh-users/zsh-completions --fpath src
zmodule completion
zmodule Aloxaf/fzf-tab

zmodule zsh-users/zsh-autosuggestions
zmodule zsh-users/zsh-syntax-highlighting

zmodule romkatv/powerlevel10k
zmodule djui/alias-tips
zmodule ohmyzsh/ohmyzsh --root plugins/autojump

Log

If applicable, use C-x . to trigger completion and provide the log.

If there are only three lines in your log, please make sure your fzf-tab is loaded with the correct order (see the checklist above).

fjchen7 avatar Jun 25 '25 05:06 fjchen7

I cannot reproduce the bug with your zshrc. Please provide the log.

Aloxaf avatar Jul 11 '25 06:07 Aloxaf

I am also facing this issue. I am on macOS 15.5 too. I am using zinit, which are different with OP's.

My result on pressing TAB after typing ls showing this:

> ls _ftb__main_complete:104: permission denied:
_ftb__main_complete:143: command not found: _complete
_ftb__main_complete:143: command not found: _ignored
_ftb__main_complete:330: permission denied:

C-x . log is here:

zsh 5.9
fzf-tab: v1.2.0.r4.gfc6f0dc
fzf-tab-debug:typeset:12: no such variable: FZF_DEFAULT_OPTS
/opt/homebrew/bin/fzf 0.52.1 (brew)
        +fzf-tab-complete:2> local -i _ftb_continue=1 _ftb_continue_last=0 _ftb_accept=0 ret=0
        +fzf-tab-complete:5> echoti civis
        +fzf-tab-complete:6> ((  _ftb_continue  ))
        +fzf-tab-complete:7> local _ftb_choices=( ) _ftb_compcap=( ) _ftb_finish=0
        +fzf-tab-complete:8> _ftb_continue=0
        +fzf-tab-complete:9> local IN_FZF_TAB=1
        +fzf-tab-complete:11> zle .fzf-tab-orig-expand-or-complete
          +-ftb-complete:1> local -Ua _ftb_groups
          +-ftb-complete:2> local choice choices _ftb_curcontext continuous_trigger print_query accept_line bs=$'\C-B' nul=$'\C-@'
          +-ftb-complete:3> local ret=0
          +-ftb-complete:6> ((  0  ))
          +-ftb-complete:7> COLUMNS=500           +-ftb-complete:7> _ftb__main_complete
           +_ftb__main_complete:1> local IFS=$' \t\n\C-@'
           +_ftb__main_complete:2> eval ''
           +_ftb__main_complete:3> local func funcs ret=1 tmp _compskip format nm call match min max i num _completers _completer _completer_num curtag _comp_force_list _matchers _matcher _c_matcher _matcher_num _comp_tags _comp_mesg mesg str context state state_descr line opt_args val_args curcontext='' _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel _tags_level=0 _saved_exact='' _saved_lastprompt=yes _saved_list=ambiguous _saved_insert=automenu-unambiguous _saved_colors='' _saved_colors_set=0 _ambiguous_color=''
           +_ftb__main_complete:4> local _comp_priv_prefix
           +_ftb__main_complete:5> unset _comp_priv_prefix
           +_ftb__main_complete:6> local -a precommands
           +_ftb__main_complete:7> local -ar builtin_precommands=( - builtin eval exec nocorrect noglob time )
           +_ftb__main_complete:8> typeset -U _lastdescr _comp_ignore _comp_colors
           +_ftb__main_complete:10> [[ -z '' ]]
           +_ftb__main_complete:10> curcontext=:::
           +_ftb__main_complete:11> zstyle -s :completion::::: insert-tab tmp
           +_ftb__main_complete:11> tmp=yes
           +_ftb__main_complete:12> [[ yes = *pending(|[[:blank:]]*) || yes = *pending=(#b)([0-9]##)(|[[:blank:]]*) ]]
           +_ftb__main_complete:17> [[ automenu-unambiguous = tab* ]]
           +_ftb__main_complete:28> [[ '' = \* ]]
           +_ftb__main_complete:34> [[ -z '' ]]
           +_ftb__main_complete:36> [[ -o equals ]]
           +_ftb__main_complete:36> compset -P 1 '='
           +_ftb__main_complete:39> [[ '' != */* && '' = \~ ]]
           +_ftb__main_complete:53> _setup default
_ftb__main_complete:53: command not found: _setup
            +_p9k_on_expand:1> ((  _p9k__expanded && ! 0  ))
            +_p9k_on_expand:1> [[ UTF-8 == (utf|UTF)(-|)8 ]]
            +_p9k_on_expand:1> return
           +_ftb__main_complete:54> _def_menu_style=( '' )
           +_ftb__main_complete:55> _last_menu_style=( )
           +_ftb__main_complete:56> zstyle -s :completion:::::default list-prompt tmp
           +_ftb__main_complete:61> zstyle -s :completion:::::default select-prompt tmp
           +_ftb__main_complete:66> zstyle -s :completion:::::default select-scroll tmp
           +_ftb__main_complete:71> ((  0  ))
           +_ftb__main_complete:86> zstyle -a :completion::::: completer _completers
           +_ftb__main_complete:86> _completers=( _complete _ignored )
           +_ftb__main_complete:88> _completer_num=1
           +_ftb__main_complete:89> integer SECONDS=0
           +_ftb__main_complete:100> funcs=( )
           +_ftb__main_complete:101> compprefuncs=( )
           +_ftb__main_complete:106> tmp=_complete
           +_ftb__main_complete:108> [[ -n '' ]]
           +_ftb__main_complete:111> [[ _complete = *:-* ]]
           +_ftb__main_complete:115> [[ _complete = *:* ]]
           +_ftb__main_complete:120> _completer=complete
           +_ftb__main_complete:122> curcontext=:::
           +_ftb__main_complete:123> zstyle -t :completion::::: show-completer
           +_ftb__main_complete:124> zstyle -a :completion::::: matcher-list _matchers
           +_ftb__main_complete:124> _matchers=( '' )
           +_ftb__main_complete:125> _matcher_num=1
           +_ftb__main_complete:126> _matcher=''
           +_ftb__main_complete:127> _c_matcher=
           +_ftb__main_complete:129> [[ '' == +* ]]
           +_ftb__main_complete:133> _matcher=''
           +_ftb__main_complete:135> _comp_mesg=''
           +_ftb__main_complete:136> [[ -n '' ]]
           +_ftb__main_complete:143> _complete
_ftb__main_complete:143: command not found: _complete
           +_ftb__main_complete:148> ((  _matcher_num++  ))
           +_ftb__main_complete:150> [[ -n '' ]]
           +_ftb__main_complete:151> ((  _completer_num++  ))
           +_ftb__main_complete:106> tmp=_ignored
           +_ftb__main_complete:108> [[ -n '' ]]
           +_ftb__main_complete:111> [[ _ignored = *:-* ]]
           +_ftb__main_complete:115> [[ _ignored = *:* ]]
           +_ftb__main_complete:120> _completer=ignored
           +_ftb__main_complete:122> curcontext=:::
           +_ftb__main_complete:123> zstyle -t :completion::::: show-completer
           +_ftb__main_complete:124> zstyle -a :completion::::: matcher-list _matchers
           +_ftb__main_complete:124> _matchers=( '' )
           +_ftb__main_complete:125> _matcher_num=1
           +_ftb__main_complete:126> _matcher=''
           +_ftb__main_complete:127> _c_matcher=
           +_ftb__main_complete:129> [[ '' == +* ]]
           +_ftb__main_complete:133> _matcher=''
           +_ftb__main_complete:135> _comp_mesg=''
           +_ftb__main_complete:136> [[ -n '' ]]
           +_ftb__main_complete:143> _ignored
_ftb__main_complete:143: command not found: _ignored
           +_ftb__main_complete:148> ((  _matcher_num++  ))
           +_ftb__main_complete:150> [[ -n '' ]]
           +_ftb__main_complete:151> ((  _completer_num++  ))
           +_ftb__main_complete:153> curcontext=:::
           +_ftb__main_complete:154> [[ '' = keep ]]
           +_ftb__main_complete:158> nm=0
           +_ftb__main_complete:160> [[ '' = keep || nm -gt 1 ]]
           +_ftb__main_complete:285> [[ nm -lt 1 && -n '' ]]
           +_ftb__main_complete:289> [[ nm -eq 0 && -z '' && 0 -ne 0 ]]
           +_ftb__main_complete:303> [[ -n '' ]]
           +_ftb__main_complete:309> [[ '' = always || '' = ?* ]]
           +_ftb__main_complete:311> [[ '' = keep ]]
           +_ftb__main_complete:319> ((  0  ))
           +_ftb__main_complete:323> unset ZLS_COLORS
           +_ftb__main_complete:326> funcs=( )
           +_ftb__main_complete:327> comppostfuncs=( )
           +_ftb__main_complete:332> _lastcomp=( list_lines 0 all_quotes '\' nmatches 0 restore auto context command vared '' unambiguous '' list_max 100 unambiguous_cursor 1 list ambiguous insert_positions '' unambiguous_positions '' to_end match last_prompt yes pattern_insert menu ignored 0 insert automenu-unambiguous )
           +_ftb__main_complete:333> _lastcomp[nmatches]=0 _ftb__main_complete:333: _lastcomp: assignment to invalid subscript range

        +fzf-tab-complete:11> ret=1
        +fzf-tab-complete:12> ((  ! ret && ! _ftb_finish  ))
        +fzf-tab-complete:16> IN_FZF_TAB=0
        +fzf-tab-complete:18> ((  _ftb_continue  ))
        +fzf-tab-complete:6> ((  _ftb_continue  ))
        +fzf-tab-complete:25> echoti cnorm
        +fzf-tab-complete:26> zle .redisplay
        +fzf-tab-complete:27> ((  _ftb_accept  ))
        +fzf-tab-complete:28> return 1

minty99 avatar Jul 11 '25 16:07 minty99

@minty99 Can you put autoload -Uz compinit; compinit before fzf-tab and try again?

Aloxaf avatar Jul 16 '25 08:07 Aloxaf

@Aloxaf it works! thank you. But I don't know why it works - could you explain? Is the line necessary?

minty99 avatar Jul 16 '25 10:07 minty99

@minty99 This is used to initialize the zsh completion system. Frameworks like zimfw usually handle this for you, but if you're using a plugin manager like zinit, you'll need to call it yourself.

Aloxaf avatar Jul 17 '25 00:07 Aloxaf