Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Hello I open my terminal window on Mac Os 10.6.8 as I am trying to update my ruby to 1.9.3 and the terminal gives me this response immediately as I open it:

-bash: export: /Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier 
-bash: export:/Library/Frameworks/Python.framework/Versions/2.7/bin': not a valid identifier
-bash: export: /Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier 
-bash: export:/Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier 
-bash: export: /usr/bin': not a valid identifier 
-bash: export:/bin': not a valid identifier 
-bash: export: /usr/sbin': not a valid identifier 
-bash: export:/sbin': not a valid identifier 
-bash: export: /usr/local/bin': not a valid identifier 
-bash: export:/usr/local/git/bin': not a valid identifier 
-bash: export: /usr/X11/bin': not a valid identifier 
-bash: export:/Users/oskarniburski/.rvm/bin': not a valid identifier 
-bash: export: /usr/X11R6/bin': not a valid identifier 
-bash: export:/Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier 
-bash: export: /Library/Frameworks/Python.framework/Versions/2.7/bin': not a valid identifier 
-bash: export:/Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier 
-bash: export: /Library/Frameworks/Python.framework/Versions/Current/bin': not a valid identifier 
-bash: export:/usr/bin': not a valid identifier 
-bash: export: /bin': not a valid identifier 
-bash: export:/usr/sbin': not a valid identifier 
-bash: export: /sbin': not a valid identifier 
-bash: export:/usr/local/bin': not a valid identifier 
-bash: export: /usr/local/git/bin': not a valid identifier 
-bash: export:/usr/X11/bin': not a valid identifier 
-bash: export: /Users/oskarniburski/.rvm/bin': not a valid identifier 
-bash: export:/usr/X11R6/bin': not a valid identifier

I tried to change my path but it did not work. I am not sure how to go about this problem and have been reading a whack load of forums. Any ideas?

Here is the bash_profile:

$ /bin/cat ~/.bash_profile

# Setting PATH for MacPython 2.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH

# Setting PATH for MacPython 2.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

# Setting PATH for EPD_free-7.3-2
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH

# Setting PATH for Python 3.3
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}"
export PATH

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/2.7/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/Current/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/git/bin /usr/X11/bin /Users/oskarniburski/.rvm/bin /usr/X11R6/bin
export PATH=/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/2.7/bin /Library/Frameworks/Python.framework/Versions/Current/bin /Library/Frameworks/Python.framework/Versions/Current/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/git/bin /usr/X11/bin /Users/oskarniburski/.rvm/bin /usr/X11R6/bin

##
# Your previous /Users/oskarniburski/.bash_profile file was backed up as /Users/oskarniburski/.bash_profile.macports-saved_2013-09-26_at_17:32:30
##

# MacPorts Installer addition on 2013-09-26_at_17:32:30: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
share|improve this question
3  
You have an error in one of your bash initialization files. Please post the contents of ~/.bash_profile and .profile if you are using the OSX terminal app and ~/.bashrc if you are using another terminal. –  terdon Sep 26 '13 at 21:43
    
Can you tell me how to access the contents of that file? Should I be using terminal? am trying nano .bash_profile to access it but that is not working. I will post the contents afterwards! Thank you so much! –  Rakso Zrobin Sep 26 '13 at 22:11
    
Just open a terminal and run this cat ~/.bash_profile and then cat ~/.profile. If one of the two files does not exist, don't worry, just post the one you have. –  terdon Sep 26 '13 at 22:16
    
I really do appreciate the help, but $ cat ~/.bash_profile -bash: cat: command not found $ cat ~/.profile -bash: cat: command not found –  Rakso Zrobin Sep 26 '13 at 22:30
2  
The two lines under the RVM stuff are unquoted and breaking your shell.. –  jasonwryan Sep 26 '13 at 22:56

1 Answer 1

up vote 1 down vote accepted

OK, the main issue here was that you had spaces separating directory entries in your $PATH and that you had these spaces in non quoted variables which confused bash.

What you wanted to do in this case was add a directory to your path. The correct syntax is PATH="/foo:/bar/baz:$PATH. Adding the $PATH to the end means that its current value will be appended to the end of the variable, that way you will not overwrite what was already there. The directories in $PATH are read in order so add it to the beginning if you want the new directories to be searched last: PATH="$PATH:/foo:/bar".

Another problem was that you had many duplicate paths. You can find these by running

$ echo $PATH | perl -pne 's/:/\n/g' | sort | uniq -d
/bin
/Library/Frameworks/Python.framework/Versions/2.7/bin
/Library/Frameworks/Python.framework/Versions/3.3/bin
/Library/Frameworks/Python.framework/Versions/Current/bin
/sbin
/usr/bin
/usr/local/bin
/usr/sbin

Finally, you were exporting the $PATH multiple times which is pointless. I removed all duplicates and fixed your syntax and ended up with this:

# Setting PATH for MacPython 2.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

# Setting PATH for Python 3.3
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}"

# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 
PATH="/usr/local/git/bin:/usr/X11/bin:/Users/oskarniburski/.rvm/bin:/usr/X11R6/bin:$PATH"

##
# Your previous /Users/oskarniburski/.bash_profile file was backed up 
# as /Users/oskarniburski/.bash_profile.macports-saved_2013-09-26_at_17:32:30
##

# MacPorts Installer addition on 2013-09-26_at_17:32:30: adding an appropriate PATH 
# variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

# Finished adapting your PATH environment variable for use with MacPorts.

Copy that file, open your terminal and run these commands:

/bin/cp ~/.bash_profile ~/bash_profile.bad
/bin/cat > ~/.bash_profile

The first will make a backup of your current ~/.bash_profile (just in case). The second will appear to do nothing but it will have opened ~/.bash_profile for writing. Just paste what I gave above directly into the terminal then hit Enter and then CtrlC. That should bring everything back to normal.

NOTE: You were specifying /bin,/sbin,/usr/bin and /usr/local/bin in your .bash_profile. These are almost certainly already in your $PATH and don't need to be added. If they are missing (echo $PATH to see the current value) just add them using the syntax I described above.

share|improve this answer
    
Thank you so much terdon. You were a great help and I appreciate it so much. If there was a way I could pay you back I would, but I am very grateful! –  Rakso Zrobin Sep 26 '13 at 23:33
    
@RaksoZrobin you're very welcome. If you want to pay me back, accept this answer and come back and upvote it when you have the reputation :). –  terdon Sep 26 '13 at 23:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.