I'm using zsh as my shell on mac OS M1 Pro Monterrey. When I echo my path I get
/Users/vcui/bin:/usr/local/bin:/Users/vcui/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/vcui/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
However typing in any commands like node or nvm gives me "zsh: command not found". My ~/.zshrc starts with
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
I've also first sourced my ~/.zshrc before running node or nvm.
Since I have the PATH specified in my ~/.zshrc, why are all of the program commands unrecognized?
I am not able to run a Julia file from the command line despite being able to use Julia fine from inside the REPL and Atom. I receive a zsh: command not found: julia error when I try that. Based on this resource, I ran export PATH="/Applications/Julia-1.4.2.app/Contents/Resources/julia/bin:$PATH" and sudo ln -s /Applications/Julia-1.4.2.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia but it did not resolve the issue. Is there anything else I could try?
edit: I am running macOS Catalina 10.15.5
ls -a /Applications/ showed that the file is actually named Julia-1.4.app
I have installed zsh and oh my zsh on Ubuntu 18.04. I would like to use autocompletion for kubectl. Therefore I have added source <(kubectl completion zsh) to my ~/.zshrc file.
On execution of this script zsh gets the following error:
complete:13: command not found: compdef
The kubectl documentation states that when one gets the error above, you should put the following on top of the .zshrc file:
autoload -Uz compinit
compinit
After doing this and restarting the terminal, I get the same error.
In a git-issue I found the following helped people with a common issue:
#This will perform chmod g-w for each file returned by compaudit to remove write access for group
compaudit | xargs -I % chmod g-w "%"
#This will perform chown to current user (Windows and Linux) for each file returned by compaudit
compaudit | xargs -I % chown $USER "%"
#Remove all dump files (which normally speed up initialization)
rm ~/.zcompdump*
#Regenerate completions file
compinit
zsh logs the following while running the script:
kubescript:12457: command not found: _bash_comp
Unfortunately this did not solve my problem. What else can I do to fix my issue? Or even still: what can I do to find out what is causing it?
I fixed the error by using the following code in .zshrc:
# K8s auto-complete
autoload -U +X compinit && compinit
source <(kubectl completion zsh)
You may also do it using oh-my-zsh plugin if you use oh-my-zsh.
I had the same issue and it was solved updating nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
For my OSX 10.15.7 I did something similar
vi ~/.zshrc
alias k=kubectl
autoload -U +X compinit && compinit
[[ /usr/local/bin/kubectl ]] && source <(kubectl completion zsh)
Works like a charm!
I encountered this after installing the Angular CLI. Turns that Angular adds something into your .zshrc file.
If you recently installed Angular CLI, open ~/.zshrc and remove the lines added by Angular CLI.
After trying lot of options and going through diff treads. It worked for me after running below command
autoload -Uz compinstall && compinstall
This configures the ~/.zshrc and initialize the compinit by adding these 2 below lines:
autoload -Uz compinit
compinit
and then run below sudo commands which mentioned in link
$ sudo chmod -R 755 /usr/local/share/zsh
$ sudo chown -R root:staff /usr/local/share/zsh
$ compaudit | xargs chmod g-w
at last restart the terminal.
Hope this helps for someone.
In my case the issue was fixed after re-installing oh-my-zsh:
Deleted my old version rm -rf ~/.oh-my-zsh
Installed from https://github.com/ohmyzsh/ohmyzsh
I really tried every answer here, but nothing worked.
So, I tried this tutorial paying attention to the last observation:
"Note: Make sure you add this snippet before any call to compdef else you will still see the error"
I had a complete call from Terraform installation in my ~/.zshrc and ~/.bash_profile files.
https://thysmichels.com/2020/07/16/mac-solved-command-not-found-compdef/
For me I had this line:
source ~/.oh-my-zsh/plugins/git/git.plugin.zsh
In my ~/.zshrc file. Which was trying to source the plugin before it is loaded by plugins=(git)
Removing that line fixed it for me.
If you have added the plugins and everything works well, One of the reasons is you may be trying to use the plugin before it is loaded. As in my case.
This issue is (also) faced after installing Angular CLI (Angular Version 14.x) and accepting addition of autocompletion for the cli commands. Snippet from .zshrc:
# Load Angular CLI autocompletion.
source <(ng completion script)
Commenting out the source line resolved the issue for me (macOS 12.6 (21G115)).
# Load Angular CLI autocompletion.
# source <(ng completion script)
Still need to work out the root cause.
Just installed iTerm2 with oh-my-zsh, with atom already installed..
I have cloned a git repo of mine to use on an older laptop and for some reason oh-my-zsh is not opening my atom on the usual command.
➜ LandingPage git:(master) atom .
zsh: command not found: atom
Tried rectifying it by accessing and changing the .zshrc file but permission is denied. Anyone any suggestions?
Thanks,
Ant
As per this question/answer it looks like atom may not have created a symlink to the atom command.
This has nothing to do with zsh -- the first argument is just telling you the shell, the information after it is the error.
For example on my machine (which doesn't have atom) when running zsh and trying to open a file with atom I get zsh: command not found: atom. When I try the same command with bash, I get bash: atom: command not found.
Let me know if the above link doesn't work! Hopefully this helps.
I'm using zsh on my Ubuntu VPS.
When I try to find version
php -v
zsh: command not found: php
and my php executable somehow got into
whereis php
php: /usr/share/php
How can I point it to right path?
export PATH=$PATH:/usr/share/php/bin
Add this to your .zshrc (assuming /usr/share/php/bin is the directory in which the php binary lives).
Ho you have to over write all commands to zsh
try this
PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
export PATH
Just reinstall PHP and overwrite any previous installation with this:
brew link --overwrite php