Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Although this question is being answered many times, I could not find any help from previous posts, so here it is again.

I have tried to add a new route to PATH variable with no success.

I have added the following command:

export PATH=$PATH:/usr/local/zend/share/ZendFramework/bin

to this files one at a time: ~/.profile, ~/.bash_profile, ~/.bashrc

After starting a new Terminal session I type

env

but the PATH variable never show the changes.

EDIT:

Seems that none of this files are being read when opening terminal, other routes where in this files and they are not being added either. On starting terminal I get this message "-bash: : command not found". If I execute

source ~/.profile

I get the route added to the PATH but it does not keep for the next Terminal session. How can I test what is happening on Terminal startup?

This are the contents of the files:

~/.profile

export PATH=/applications/MAMP/bin/php5.3/bin/:$PATH
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
export PATH=/usr/local/zend/share/ZendFramework/bin:$PATH

~/.bashrc

export PATH=$PATH:/usr/local/zend/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/zend/lib

~/.bash_profile is empty

None of the routes in any of them are displayed after typing

env

in Terminal.

share|improve this question
    
Put some echo lines in the files to see what gets executed –  Mark Jul 20 '11 at 9:28
1  
You're doing it right. That should work. –  Joel Spolsky Jul 20 '11 at 23:08
    
@Mark, what do you mean with adding echo lines? –  David Casillas Jul 21 '11 at 8:41
    
echo - $PATH will print out the path , put different echo "comment" in the files to show which ones are being used –  Mark Jul 21 '11 at 8:58
1  
In Terminal Preferences what are values of "Shells open with" and also Settings->Shell->Run command –  Mark Jul 21 '11 at 10:11

3 Answers 3

well first off you only really need it in ~/.bash_profile if you have one.

Second opening a new terminal session without quitting terminal app will not source the ~/.bash_profile file.

You can just type "source ~/.bash_profile" in the terminal and it should pick up your new settings.

Or quit terminal.app and restart it.

share|improve this answer
    
I always quit and restart Terminal to verify the changes. –  David Casillas Jul 21 '11 at 8:37
    
+1, the changes always need to go into bash_profile on OS X, .profile never works from the home directory only from /etc/, so bash_profile is the recommended place to go. –  Nicholas Smith Sep 19 '11 at 10:20

Try changing the export to:

export PATH=/usr/local/zend/share/ZendFramework/bin:$PATH

in your ~/.profile

share|improve this answer
    
Marconcini, there is no difference is setting the new route after or before the previous PATH. –  David Casillas Jul 21 '11 at 8:38

The problem is in how you are testing the changes.

Run the following command in Terminal to test your changes.

source ~/.profile

Once it looks correct, start a new window and re-verify the settings.

Every time you run the source command it will add the same path to your $PATH variable.

share|improve this answer
    
the sourcecommand works but only while the session is not closed. See my edits to the post. –  David Casillas Jul 21 '11 at 8: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.