When defining or exporting a variable, you should not use $
:
export PATH=/Users...
Otherwise, the current value of PATH
will be substituted into the export
statement.
Frage
While messing around with zsh today and getting something configured properly for ruby, I got the following error.
/Users/secallahan/.zshrc:export:54: not valid in this context: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin
Here is my .zshrc (around line 54, where the error occurs) file that I edited.
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
....
....
# User configuration
export $PATH=/Users/secallahan/.rvm/gems/ruby-2.1.1/bin:/Users/secallahan/.rvm/gems/ruby-2.1.1@global/bin:/Users/secallahan/.rvm/rubies/ruby-2.1.1/bin:/Users/secallahan/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin
# export MANPATH="/usr/local/man:$MANPATH"
This was the only way I was able to make it. So then I opened a new shell and did ruby -v
and got ruby2.1.1 as the current version.
Any help would be very much appreciated.
Lösung
When defining or exporting a variable, you should not use $
:
export PATH=/Users...
Otherwise, the current value of PATH
will be substituted into the export
statement.
Andere Tipps
You left out the double quotes too. This was my case, I had to change the syntax from
export PATH=/usr/local/opt/node@12/bin/ to
export PATH="/usr/local/opt/node@12/bin:$PATH"
This can also be caused by using pasted incorrect double quotes for your value To fix it delete your double quotes and type them in terminal
For example:
export CPPFLAGS=“-I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/zlib/include”
is wrong and needs to be:
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/zlib/include"