zsh error: export:54: not valid in this context: - shell

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.

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.

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"

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"

Related

Terminal showing environment variables on startup

Since today my terminal shows all kind of variables on startup.
This is my ~/.zshrc file:
I don't think something bad will come of it but I'm just wondering how this happened and how I can turn it back off.
Thankyou for your help!
export is called as a command, and shows all the exported vars.
You should make the
export
JAVA_HOME=...
A single line, so export isn't called without args:
export JAVA_HOME= ...

bash_profile Powerline setup

I am learning the command line and trying to customize my environment to have Powerline functionality.
I have installed the Powerline file from GitHub and am trying to add to my path variable.
My .bash_profile is set as follows:
export PATH=$PATH:$HOME/Library/Python/2.7/bin
export PATH=$PATH:$HOME/Library/Python/2.7/binpowerline-daemon -qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh
I receive the following error messages when launching terminal.
-bash: export: `-qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1': not a valid
identifier
-bash: export: `/Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh':
not a valid identifier
I would appreciate any guidance in the right direction on this issue. Thank you.
The stuff you added needs to be broken up on individual lines with newlines between them. I can only guess where the newlines are supposed to go, but something like
export PATH=$PATH:$HOME/Library/Python/2.7/bin
# No need to repeat this
# export PATH=$PATH:$HOME/Library/Python/2.7/bin
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh

Log: "bash: export: "PATH.": not a valid identifier" when opening terminal on Ubuntu

Whenever I open a terminal, a message appear on top of it saying what I wrote in the title.
I think I messed up with the /etc/profile file when trying to get maven work.
I read some infos on exporting variables, but couldn't find my error, since I followed a guide that worked fine for other people.
The profile file I mentioned has these lines at bottom:
JAVA_HOME=/usr/local/java/jdk1.8.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.8.0
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Setting $JAVA_HOME let me use properly Maven, but creates this annoying message. Can you help me?
As others mentioned in the comments, you are trying to export PATH. instead of PATH somewhere. You might want to check /etc/profile, ~/.bashrc and ~/.bash_profilefiles and try to find this invalid export.
The source you provided is technically ok and you don't need to add any $ signs. Your PATH will contain $HOME/bin value twice though. You might want to change it to look like this:
export JAVA_HOME=/usr/local/java/jdk1.8.0
export JRE_HOME=/usr/local/java/jre1.8.0
export PATH="$PATH:$HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin"

Unable to open bash profile on OSX

I am unable to open bash profile. I had set the Java and Android path but suddenly it is opening. But when I run echo $PATH it is displaying the paths correctly. Now I need to add path to bash profile.
Could anyone please help me?
Your $PATH is wrong :
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/Users/qsgte‌​chnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Andr‌​oid/sdk/tools
This doesn't use standard default path, and, unless this is totally intentional, I recommend you not to do this.
You've got to fix it running this (note /bin:/usr/bin:):
export PATH=/bin:/usr/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/Users/qsgte‌​chnologies/Library/Android/sdk/platform-tools:/Users/qsgtechnologies/Library/Andr‌​oid/sdk/tools:
The next time, be sure to use this syntax:
export PATH=$PATH/YourNewPath:
Since you removed /bin:/usr/bin: you where unable to change your bash profile because bash wasn't able to locate your executables.
Fitting your needs, here's your current bash_profile:
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/qsgtechnologies/Library/Android/sdk
export PATH=$JAVA_HOME/bin:/usr/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
Change it to (note that YourNewEntry is a placeholder for the value you need)
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/qsgtechnologies/Library/Android/sdk
export PATH=$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:/YourNewEntry
Then apply your changes:
source ~/.bash_profile

Terminal error in mac

I used to do something to change the looking my of macbook terminal(adding color to character, etc). However, since than, when ever I try "ls", it always gave the error like:
error : invalid character '' in LSCOLORS env var.
How to set up my env to fix it please?
Update: I fixed the problem by fix my .bash_profile in changing to
export LSCOLORS=ExFxCxDxBxegedabagacad
figure out your current setting - run 'grep "LSCOLORS=" ~/.bash_profile'
open your ~.bash_profile, find the LSCOLORS definition. Change it as follows:
export CLICOLOR=1
export LSCOLORS=Gxfxcxdxbxegedabagacad
You must have added a line beginning with LSCOLORS= some character to your .bash_profile. Open it in terminal with nano ~/.bash_profile or using TextEdit and remove that line.

Resources