5

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?

0

3 Answers 3

7
+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

3

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.

0

I found a clue or at least another case where it fails. This also places ?part of? the blame on zsh. Make sure you actually track down where your errors are occurring. I am moving to zsh from bash, and trying to keep as much common in my .rc files. One thing that is now failing are assignments like this (a BASH idiom):

: ${*var*:=DEF_VAR_VAL}
zsh: :: function definition file not found
# `:=' may also be one of =, :=, etc.
# Oddly, the operator works anyway and *var* is set if needed.
# However, the following works w/nary a problem:
var=${var-DEV_VAR_VAL}
# as does:
true ${var:=DEF_VAR_VAL}
# Odd, because `:' is supposed to be an alias for true(1)

The doc still says : should work, and it used to.

: [ arg ... ] This command does nothing, although normal argument expansions is[sic] performed which may have effects on shell parameters. A zero exit status is returned.

Source: http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html

NB: I'm seeing neither italics nor bold in my preview, so they may not show up.

1
  • Where do you expect italicized text to appear? Markdown syntax is treated as code (i.e. not rendered on the page) when you encapsulate it in a code block. You need to use a quote block rather if you want it to show up (render) on the page.
    – Samir
    May 23, 2021 at 23:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .