I just encourage a weird problem with zsh today.
My environment is Mac OS X Yosemite, zsh 5.0.5 (x86_64-apple-darwin14.0)
In .zshrc, I have manually set the PATH variable to something like
export PATH="$PATH:~/.composer/vendor/bin"
Try echo $PATH
in terminal, the result is as expected (contained ~/.composer/vendor/bin
). Then try executing a binary from ~/.composer/vendor/bin
, It'll always return me "zsh: command not found" error.
Try switching to bash, echo $PATH
is also as expected, have the same result as zsh shell.
Try executing a binary from ~/.composer/vendor/bin
, no problem found. Seem the PATH var is acting well on the bash shell.
What's wrong with my zsh shell?
Thanks
Try using $HOME
instead of ~
. In many situations, shells do not expand ~
when you expect them to and it is usually better to use $HOME
. ~
is really only intended to be a short cut for interactive use. (The only case I can recall where ~
was preferred was in a .gitalias, where ~ was expanded and variables were not.)