0

When I start terminal I get the error

-bash: export: `PATH;': not a valid identifier

Why?

I've looked in the two files which I think bash uses at startup, and I cannot see an issue:

/etc/profile

# 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  

~/.bash_profile

export PATH="$PATH:/usr/local/autoconf/bin"  
export PATH="$PATH:/usr/local/automake/bin"  
export VISUAL=vscodeeval $(/usr/libexec/path_helper -s)  

(N.B. The file /usr/libexec/path_helper is binary, and /etc/bashrc does not contain the text 'PATH'.)

Where is the error coming from? I cannot see PATH; with the trailing semicolon in either startup profile.

4
  • What are you trying to achieve in the last line of your bash_profile?
    – fd0
    Commented Feb 8, 2017 at 11:08
  • I'm not, I think that's the out-of-the-box profile. At least none of it looks familiar to me.
    – dumbledad
    Commented Feb 8, 2017 at 11:31
  • But removing that line fixes things! Thanks. I wonder what added it.
    – dumbledad
    Commented Feb 8, 2017 at 11:36
  • I've added this as a VS Code issue here just-in-case.
    – dumbledad
    Commented Feb 8, 2017 at 11:44

2 Answers 2

3

Look at the output of path_helper -s:

$ /usr/libexec/path_helper -s
PATH="..."; export PATH;

(The actual value assigned to PATH isn't important; I've elided it here.)

The output is intended to be executed with eval, as it is in /etc/profile. The purpose is to provide an initial value for the PATH variable, then set the export attribute on the name.

In your .bash_profile, you are unnecessarily executing it again, but also incorrectly letting the output be used as additional arguments to an export command. The line

export VISUAL=vscodeeval $(/usr/libexec/path_helper -s) 

is treated as

export VISUAL=vscodeeval PATH="..."; export PATH;

except the semicolons are treated as literal characters, not command terminators. Thus, it tries to do the following:

  1. Set VISUAL to vscodeval and set the export attribute on VISUAL. That's OK.

  2. Set PATH to an initial value (ending with a semicolon, which would not be what you want, but syntactically not an issue) and set its export attribute.

  3. Set the export attribute on a variable named export. Unnecessary, but not an error.

  4. Set the export attribute on a variable named PATH;. That is your error, since a variable name cannot contain a ;.

The fix is to just remove the $(/usr/libexec/path_helper -s) from your .bash_profile; it only needs to be executed once from /etc/profile.

1

Just to turn fd0's comment into an answer, the offending line in my ~/.bash_profile file is the last one

export VISUAL=vscodeeval $(/usr/libexec/path_helper -s)  

Removing that line fixes the problem and appears to have no bad effects. Sadly I cannot remember nor work out why it was there

0

You must log in to answer this question.

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