2

My oh-my-zsh install which has been working for almost a year has just broken. When I open a terminal, I get:

/home/marcel/.oh-my-zsh/lib/theme-and-appearance.zsh:2: colors: function definition file not found
/home/marcel/.oh-my-zsh/oh-my-zsh.sh:78: compinit: function definition file not found
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:80: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:93: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:100: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:109: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:119: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:129: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:138: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:144: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:147: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:150: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:153: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:163: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:166: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:168: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:182: command not found: compdef
/home/marcel/.oh-my-zsh/plugins/git/git.plugin.zsh:193: command not found: compdef
$SPACESHIP_PROMPT_TRUNC is deprecated. Use $SPACESHIP_DIR_TRUNC instead.
spaceship_setup:3: add-zsh-hook: function definition file not found
spaceship_setup:4: add-zsh-hook: function definition file not found
$SPACESHIP_PROMPT_TRUNC is deprecated. Use $SPACESHIP_DIR_TRUNC instead.
spaceship_setup:3: add-zsh-hook: function definition file not found
spaceship_setup:4: add-zsh-hook: function definition file not found

I have looked around and a lot of other answers suggest running compaudit. Running this gives me zsh: compaudit: function definition file not found.

What I have tried:

  1. rm ~/.zcompdump*
  2. Reinstalling oh-my-zsh
  3. Reinstalling zsh from source
  4. Adding /usr/share/zsh/functions to $fpath
  5. chown -R 755 /usr/share/zsh/functions
  6. Loading and running compaudit inside of zsh -f

My environment:

  • uname -a: Linux Hermes 4.11.6-1-ARCH #1 SMP PREEMPT Sat Jun 17 08:19:42 CEST 2017 x86_64 GNU/Linux
  • zsh --version: zsh 5.3.1 (x86_64-unknown-linux-gnu)
  • which zsh: /usr/local/bin/zsh

Edit:

I have confirmed that it is a permissions problem. If I do

sudo zsh -f
autoload -U compaudit
compaudit

The command works as expected. I then did

sudo chmod 777 /usr/share/zsh/ -R # Just for testing I promise

and I still got zsh: compaudit: function definition file not found when running compaudit.

I also tried

sudo chown user:users /usr/share/zsh/ -R

and it's still not working. If all these files are owned by my user AND are 777 how does zsh work as root and not as my user?

  • It was my $FPATH. I should have known. I tried adding stuff to it but I guess I added the wrong stuff. I just copied it over from root because root works fine and now everything is perfect. Thanks a lot! – Marcel Jun 30 '17 at 12:12
  • Write that up nicer in an answer and I'll give you the bounty. – Marcel Jun 30 '17 at 12:12
2
+50

As per a clue in installation problems with colors, compinit and git plugin #4757, it seems that verifying the "$FPATH variable content" contains the correct path for where you installed the functions should help resolve the problem.

Furthermore, copying the zsh contents over to a location such as the root or a path already defined in $FPath may help resolve this problem as well.

The first thing to do is verify your FPATH variable content: echo $FPATH. In a normal situation return something like that: /home/charmander/.oh-my-zsh/plugins/git:/home/charmander/.oh-my-zsh/functions:/home/charmander/.oh-my-zsh/completions:/home/charmander/.oh-my-zsh/plugins/python:/home/charmander/.oh-my-zsh/plugins/pip:/home/charmander/.oh-my-zsh/plugins/git:/home/charmander/.oh-my-zsh/functions:/home/charmander/.oh-my-zsh/completions:/usr/share/zsh/site-functions:/usr/share/zsh/5.0.2/functions.

In my case it returned: /opt/intel/composer_xe_2011_sp1.7.256/mkl/include. When I try to remove .oh-my-zsh and run only zsh returned this: /usr/share/zsh/5.0.2/scripts/newuser:6: zsh-newuser-install: function definition file not found. Search in web I found this bug report: zsh: Many function definitions are missing zsh-newuser-install, compinit, etc that say it could have a variable overwrite made by Intel compiler :/

So a workaround to this problem could be insert the following lines to your .bash_profile, if you can not run this command chsh -s $(which zsh).

FPATH=/home/modelagem/beatriz.fonseca/.oh-my-zsh/plugins/python:/home/modelagem/beatriz.fonseca/.oh-my-zsh/plugins/pip:/home/modelagem/beatriz.fonseca/.oh-my-zsh/plugins/git:/home/modelagem/beatriz.fonseca/.oh-my-zsh/functions:/home/modelagem/beatriz.fonseca/.oh-my-zsh/completions:/usr/share/zsh/site-functions:/usr/share/zsh/5.0.2/functions

export FPATH

source

Additionally as per a clue from colors: function definition file not found #4607, it appears that others have solved this problem by adding $HOME/usr/share/zsh/'version of zsh'/functions to solve this as installing zsh as $HOME/usr can cause this issue.


Further Reading

   FPATH  The search path for function definitions.  The directories in this  path  are  searched
                 for  a  file  with the same name as the function or command when a function with the -u
                 attribute is referenced and when a command is not found.  If an  executable  file  with
                 the name of that command is found, then it is read and executed in the current environ-ment. environment.
                 ment.  Unlike PATH, the current directory must be represented explicitly by  .   rather
                 than by adjacent : characters or a beginning or ending :.

source


9.1 Autoloading Functions

A function can be marked as undefined using the autoload builtin (or ‘functions -u’ or ‘typeset -fu’). Such a function has no body. When the function is first executed, the shell searches for its definition using the elements of the fpath variable.

source

2

I just wanted to add a short note that this error can also happen if you have two separate versions of ZSH installed. Make sure that you don't have anything in your FPATH that would be incompatible with the version of ZSH that you're using for your actual login shell.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.