I was adding a $PATH to .bash_profile:


So I could install PEAR on MAMP. That all worked, but now I have an this error each time I start up:

-bash: export: `/usr/local/bin': not a valid identifier

I tried a lot of solutions from people with similar problems, such as:

I messed up my bash configuration on mac

These are the files possibly containing the problem:


# System-wide .profile for sh(1) if [ -x /usr/libexec/path_helper ]; then eval /usr/libexec/path_helper -s` fi if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi`




export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"


#export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"

launchctl export

    PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
    TMPDIR="/var/folders/9l/7n7rrkrj0d51ydll3hb3l8780000gn/T/"; export TMPDIR;
    SHELL="/bin/bash"; export SHELL;
    HOME="/Users/XXXXXX"; export HOME;
    USER="XXXXXX"; export USER;
    SSH_AUTH_SOCK="/tmp/launch-d3uaRv/Listeners"; export SSH_AUTH_SOCK;
    Apple_Ubiquity_Message="/tmp/launch-YdytLh/Apple_Ubiquity_Message"; export Apple_Ubiquity_Message;
    Apple_PubSub_Socket_Render="/tmp/launch-8QgJZ0/Render"; export Apple_PubSub_Socket_Render;
    DISPLAY="/tmp/launch-c6nAQC/org.macosforge.xquartz:0"; export DISPLAY;



Files in '/etc/paths.d/':



I dont have a bashrc directory at location /etc/bashrc.

I also don't have ~/.bashrc.

Maybe it is also useful that before I installed PEAR I added a symlink to /usr/bin maybe that is part of the problem?

  • 1
    I posted a possible solution. BTW, can you please modify your question by posting your entire .bash_profile? You can copy and past the result of cat ~/.bash_profile
    – Maverik
    Commented Oct 10, 2012 at 13:49
  • 1
    If you comment the line in .bash_profile, do you still have to do /bin/mv for moving a file or you can just use mv? If not, there is something wrong, because all the "shell commands" like mv are in \bin which should be in your $PATH
    – Maverik
    Commented Oct 10, 2012 at 15:00
  • 1
    Did you cut&paste the "invalid identifier" message directly from Terminal or did you type it into the question manually?
    – nohillside
    Commented Oct 10, 2012 at 18:47
  • 1
    Could you post the content of /etc/paths, each file in /etc/paths.d/, /etc/bashrc, ~/.profile, ~/.bash_profile, ~/.bashrc and the output of launchctl export and printenv? Do you use macports? Commented Oct 12, 2012 at 15:17
  • 1
    Yes, I meant that macports. But you just seem to have X11/XQuartz installed. I forgot to ask for the content of ~/.bash_login, if there is such a file. Right now, are there any problems? The only strange thing that I see that the PATH in printenv should be grander because of the stuff in ~/.profile. Commented Oct 12, 2012 at 16:28

2 Answers 2


The error message you listed is the result of using one of

 export $VARIABLE
 export /a/path/to/something
 export *more or less anything which is not a syntactically correct variable name*

instead of

 export VARIABLE

in one of your initialization files. To find the offending line you need to look into all the .profile, .bash_profile and anything sourced/called from there and grep for 'export ' to find it.

As it seams to be related to the installation of either PEAR or MAMP I would start looking at any additions done by these installations.

  • 1
    The error message is clear enough. This is the correct answer, and forget all other voodoo.. Simply, you have somewhere an commands like: VAR=/usr/local/bin ; export $VAR (instead of export VAR). You can insert at the top of your .profile set -x, open new terminal window and see what is happening...
    – clt60
    Commented Oct 12, 2012 at 22:16
  • Thanks! Any more ideas where would I find the culprit? I looked into all listed files in this thread and can't find any instance that has export $VAR instead of VAR
    – bottleboot
    Commented Oct 13, 2012 at 14:17
  • You also have to look in any files sourced/called from the standard files
    – nohillside
    Commented Oct 13, 2012 at 14:54
  • for some reason when I did a cat /etc/profile now, I got : 'export PATH=$PATH: /usr/local/bin' on the final line Which was causing the problem. Not sure who to give the answer to now.
    – bottleboot
    Commented Oct 13, 2012 at 16:04
  • 1
    Good point, I've extended the answer accordingly.
    – nohillside
    Commented Oct 18, 2012 at 13:35

You should add to your .bash_profile the following line instead of the one you reported in your question:

export PATH="$PATH:/Applications/MAMP/bin/php/php5.3.6/bin"
  • Hi, Thanks for the answer! I'm still getting that error with the changes.
    – bottleboot
    Commented Oct 10, 2012 at 13:50
  • I think the ordering there is correct, however I would still advise quoting the lot. Commented Oct 10, 2012 at 15:37
  • @DannyStaple Do you mean keep the "..."?
    – Maverik
    Commented Oct 10, 2012 at 15:44
  • 1
    Yes. I think so - if the original path expansion included other characters (okay I cannot see unescaped spaces working in the path), then you may not be including them in the assignment. General bash defensive coding... Commented Oct 10, 2012 at 15:48
  • @DannyStaple That's true, I updated my answer.
    – Maverik
    Commented Oct 10, 2012 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .