ZSH autocompletion gives seemingly random errors after some time
This could be a consequence of running some code that clobbers the variable FPATH
or fpath
. Check the value of either of these variables; it should be a list of directories where zsh loads functions.
The variables FPATH
and fpath
are tied (like PATH
and path
): changing one affects the other. The uppercase FPATH
is a string which contains a colon-separated list of directories. The lowercase fpath
is an array of directories.
Check your startup scripts for any place where you might use either of these names as variables. Check the list of variable names set or used by zsh (man zshparam
) and make sure you don't use any for different purposes.
Completion functions are autoloaded, i.e. loaded the first time they are used. Once you've done any completion in a shell instance, for example, you should no longer see _main_complete: function definition file not found
— if _main_complete
works but then stops working with this message, something weirder is going on.
Related videos on Youtube
Zulan
Updated on September 18, 2022Comments
-
Zulan over 1 year
My zsh autocompletion is broken in a strange way. For clean logins everything works but after some time I will get seemingly random autocompletion errors, for different "kinds" of autocompletion. Sometimes
ls foo<tab>
works butrm foo<tab>
won't. I am completely lost on how to debug this.I could not find a pattern to a particular command causing it. Neither could I see a pattern on what completion works and what doesn't. In my routine I use gnu modules, run make, compilers, nano etc..
The errors I get upon autocompletion look like this:
/bin/zsh:4: _main_complete: function definition file not found
or
(eval):1: _autocd: function definition file not found (eval):1: _autocd: function definition file not found (eval):1: _autocd: function definition file not found _main_complete:173: _ignored: function definition file not found _main_complete:173: _ignored: function definition file not found _main_complete:173: _ignored: function definition file not found
or
(eval):1: _rm: function definition file not found (eval):1: _rm: function definition file not found (eval):1: _rm: function definition file not found
I have seen similar messages for _sudo and _module.
I am using zsh (5.0.2) with oh-my-zsh in multiple screen sessions on a machine whose home filesystem is on nfs. I attach to the screen sessions automatically on each login with
screen -xrR
in.zprofile
Two files $HOME/.zcompdump and $HOME/.zompdump-
hostname
-5.0.2 are created whenever i login. Removing them made no difference.-
Gilles 'SO- stop being evil' about 10 yearsDoes the problem appear only the first time you use completion in a shell instance, or does it sometimes appear later as well?
-
-
Zulan about 10 yearsSorry for the late accept. You were right. Some modules on the system were setting FPATH, presumably someone thought that if CPATH is for C includes, FPATH must be the version for fortran...