Fix Mac OS X bash

1

When I start my Terminal I get this error. I have no clue how to fix that and where it comes from.

Last login: Fri Nov 30 21:46:06 on ttys000
-bash: export: `/usr/local/bin': not a valid identifier

nohayeye

Posted 2012-11-30T20:49:07.760

Reputation: 111

Answers

2

Most likely one of the 'export' command in your .bashrc or .bash_profile is mis-configured.

Open up your favorite text editor and view the file(s) in your home directory called .bashrc and .bash_profile.

Look for any lines that begin with

export

one of the lines should be

export PATH='/usr/local/bin'

there might be spaces between PATH and the first '

export PATH = '/usr/local/bin'  #<----WRONG remove spaces

if not, copy the contents here and let's have a look.

An alternative if you can't find it is to grep through your home dir or /etc:

grep -l -E '/usr/local/bin' .*

make sure you use single quotes to escape the forward slash. then look at the files it lists for the mis-typed export.

Johnnie

Posted 2012-11-30T20:49:07.760

Reputation: 262

Thank you for your answer! I already checked both files and they were empty (not existed). If I create a ~./bash_profile file with "export PATH='/usr/local/bin'" as content, the error is still there. weird :/ – nohayeye – 2012-11-30T21:03:37.947

@nohayeye Those tend to require a reboot, or at least a logout/in to take effect. Did you try that? – nerdwaller – 2012-11-30T21:06:43.457

It also might be export $PATH somewhere - the dollar sign does not belong there. – choroba – 2012-11-30T21:08:01.297

how about ~/.bash_login, ~/.profile. also how about /etc/profile. – Johnnie – 2012-11-30T21:08:59.977

just modified the answer to use grep to find the file. – Johnnie – 2012-11-30T21:20:13.590

1You cannot just export the whole path to just usr/local/bin – append the existing path as well: export PATH=/usr/local/bin:$PATH – slhck – 2012-11-30T21:38:12.980

1

OSX has used the path locations in a few files over the 10.6/7/8:

~/.profile     #local user
/etc/profile   #system wide defaults for ^
/etc/paths     #<---This is probably the one you want to check in.

Check all of those for the path's, as @choroba said above the $ is only for the end of the line, so similar to: export PATH=/opt/local/bin:/usr/sbin:$PATH

nerdwaller

Posted 2012-11-30T20:49:07.760

Reputation: 13 366

That's how they look like: http://cl.ly/LGdu No $PATH

//EDIT: Sorry wrong screenshot.

– nohayeye – 2012-11-30T21:50:20.997

@nohayeye Odd. Do command line tools work (outside of vi/m as it appears above)? I like where John was going, but I would take it further. Something like for i in \find / -maxdepth 3 -iname "profile"`; do grep -i "path" ${i}; done` I know that is how it works on linux, so it should work. Though, it may be a long search... – nerdwaller – 2012-11-30T21:59:20.330

I found another topic where someone posted his /etc/paths and /etc/profile. (http://superuser.com/questions/374204/all-commands-are-not-working-on-mac-os-x-lion) I edited my /etc/paths but the "-bash: export: `/usr/local/bin': not a valid identifier" is still there. All command line tools are working. Weeeeird!

– nohayeye – 2012-11-30T22:03:12.573

Did you reboot after update? – nerdwaller – 2012-11-30T22:03:43.443

2I found it! There was a strange $PATH line in "/etc/bashrc". I deleted it, now everything is working fine. Thanks you all for your help! :) – nohayeye – 2012-11-30T22:05:33.277