Skip to content
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

Suddenly OMZ gives compdef: command not found #10702

Closed
konsbn opened this issue Feb 16, 2022 · 19 comments
Closed

Suddenly OMZ gives compdef: command not found #10702

konsbn opened this issue Feb 16, 2022 · 19 comments
Labels
Support Request for support

Comments

@konsbn
Copy link

konsbn commented Feb 16, 2022

Discussed in https://github.com/ohmyzsh/ohmyzsh/discussions/10701

Originally posted by konsbn February 17, 2022
Out of nowhere I am being greeted with this message as I fire up a new terminal. I haven't done anything with my .zshrc or the config files.

/home/sbn/.oh-my-zsh/lib/completion.zsh:78: bashcompinit: function definition file not found
zsh: compdef: command not found...
/home/sbn/.oh-my-zsh/lib/termsupport.zsh:108: add-zsh-hook: function definition file not found
/home/sbn/.oh-my-zsh/lib/termsupport.zsh:109: add-zsh-hook: function definition file not found
/home/sbn/.oh-my-zsh/lib/theme-and-appearance.zsh:2: colors: function definition file not found
/home/sbn/.oh-my-zsh/lib/vcs_info.zsh:3: is-at-least: function definition file not found
/home/sbn/.oh-my-zsh/lib/vcs_info.zsh:3: is-at-least: function definition file not found
zsh: compdef: command not found...
zsh: compdef: command not found...
zsh: compdef: command not found...
zsh: compdef: command not found...
/home/sbn/.oh-my-zsh/plugins/git/git.plugin.zsh:140: is-at-least: function definition file not found
zsh: compdef: command not found...
zsh: compdef: command not found...
zsh: compdef: command not found...
zsh: compdef: command not found...
zsh: compdef: command not found...
zsh: compdef: command not found...
/home/sbn/.oh-my-zsh/plugins/git/git.plugin.zsh:282: is-at-least: function definition file not found
/home/sbn/.oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh:59: is-at-least: function definition file not found
zsh-syntax-highlighting: Failed to load add-zsh-hook. Some speed optimizations will not be used.
zsh-syntax-highlighting: failed loading add-zsh-hook.
/home/sbn/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh:742: add-zsh-hook: function definition file not found
zsh: compdef: command not found...

Please help me resolve this issue

@rwmitchell
Copy link
Contributor

I believe compdef is defined in:

PATH/share/zsh/VERSION/functions/compinit

where PATH and VERSION will depend on your installation.

Are those files still ok?

@mcornella
Copy link
Member

Same as #10697. Have you updated from 5.8 to 5.8.1? If so, can you post the output of typeset -p fpath?

@mcornella mcornella added the Support Request for support label Feb 16, 2022
@zapateo
Copy link

zapateo commented Feb 17, 2022

I had the same problem on Fedora 35 Workstation, after updating Zsh from 5.8 to 5.8.1.
The FPATH variable was pointing to /usr/share/zsh/5.8/functions instead of /usr/share/zsh/5.8.1/functions.

Rebooting the system solved the problem (a logout wasn't enough, not sure why).

@mcornella
Copy link
Member

Check for changes to $fpath or $FPATH in your zshrc or similar. It might be that somewhere something is doing export FPATH, which shouldn't happen ($fpath and $FPATH are tied variables and never should be exported).

@konsbn
Copy link
Author

konsbn commented Feb 17, 2022

I had the same problem on Fedora 35 Workstation, after updating Zsh from 5.8 to 5.8.1. The FPATH variable was pointing to /usr/share/zsh/5.8/functions instead of /usr/share/zsh/5.8.1/functions.

Rebooting the system solved the problem (a logout wasn't enough, not sure why).

@konsbn konsbn closed this as completed Feb 17, 2022
@mcornella
Copy link
Member

mcornella commented Feb 17, 2022

Rebooting the system solved the problem (a logout wasn't enough, not sure why).

See #10702 (comment). Can you run typeset -p fpath and post the output so I can see if it is exported?

@mcornella
Copy link
Member

If you followed the wrong advice on #4607 or other threads, it's likely you have a line in your .zshrc file saying export FPATH. YOU SHOULD DELETE THAT LINE, otherwise this problem will keep happening every time you update your zsh version.

@xapienz
Copy link

xapienz commented Feb 22, 2022

@mcornella

Can you run typeset -p fpath and post the output so I can see if it is exported?

Mine is this:

$ typeset -p fpath
typeset -aT FPATH fpath=( /home/xapienz/.oh-my-zsh/plugins/git /home/xapienz/.oh-my-zsh/functions /home/xapienz/.oh-my-zsh/completions /home/xapienz/.oh-my-zsh/cache/completions /usr/share/Modules/init/zsh-functions /usr/local/share/zsh/site-functions /usr/share/zsh/site-functions /usr/share/zsh/5.8/functions )

However, opening a new terminal doesn't solve the issue.

I didn't try to reboot and I believe that ohmyzsh updates shouldn't require reboots, so I made a symlink as a local workaround: sudo ln -s /usr/share/zsh/5.8.1 /usr/share/zsh/5.8

@rwmitchell
Copy link
Contributor

"I didn't try to reboot and I believe that ohmyzsh updates shouldn't require reboots,"

omz doesn't require a reboot, however, your system updated ZSH and apparently did so in a way that breaks current running zsh sessions.

@xapienz
Copy link

xapienz commented Feb 22, 2022

@rwmitchell You are right, I was confused between zsh and ohmyzsh upgrades, because I saw several reports like this, and thought that it was caused by ohmyzsh update. Looks like zsh itself is the culprit

@mcornella
Copy link
Member

The "workaround" is only useful until you reboot, so I don't see why you'd prefer that. If this happened because of Zsh, it'll happen again when you update to the next Zsh version.

@mcornella
Copy link
Member

Thank you for the sponsorship by the way!

@xapienz
Copy link

xapienz commented Feb 24, 2022

The "workaround" is only useful until you reboot

Yes, I did it exactly because I don't want to reboot :)
When I reboot, it will get fixed in fpath, according to comments above, and I will be safe until next time.

@tik9
Copy link

tik9 commented Aug 15, 2022

I get ln: /usr/share/zsh/5.8: Read-only file system on Mac Monterey when doing sudo ln -s /usr/share/zsh/5.8.1 /usr/share/zsh/5.8. I did csrutil disable because before it, I got permission denied with the ln command. Seems like one has to consider this

@rwmitchell
Copy link
Contributor

rwmitchell commented Aug 15, 2022

Or maybe just don’t install in /usr

Not to be flip, corporate lockdown policies are worse than Apple's. Installing non-apple programs in $HOME/local is a reasonable workaround. It also has the advantage of getting backed up with your HOME and makes it easy to keep OS updates separate from your own.

@tik9
Copy link

tik9 commented Aug 16, 2022

You mean copy zsh folder to $home/zsh from usr/share/ and then do the ln in it? Should I leave /usr/local/share/zsh as is? And I have to change the last entry of $fpath - current /usr/share/zsh/5.8.1/functions - to $home/zsh/5.8.1/functions?

@rwmitchell
Copy link
Contributor

No.

I was assuming you were installing zsh by compiling from source and could therefore use:

./configure --prefix=$HOME/local

but now you're talking about copy files from /usr/share into /usr/local/share...how did you get files in /usr/share to begin with if you can't create files there now? If you're using Apple's installation, it should already be using 'its' latest version without needing to create a symlink to it.

@tik9
Copy link

tik9 commented Aug 17, 2022

The default shell on Mac Monterey is zsh and the default zsh folder besides /bin/zsh is /usr/share. So I take your point, and try to uninstall zsh or change the system zsh dir. A google search with mac change default system zsh directory to home does not result well .So no idea how to do it. this post about installing with homebrew does not help here.

@phdbrianlee
Copy link

sudo ln -s /usr/share/zsh/5.8.1 /usr/share/zsh/5.8
solved my issue on 5.13.6-200.fc34.x86_64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Request for support
Projects
Archived in project
Development

No branches or pull requests

7 participants