Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been trying back and forth to set environment variables in the Terminal.app but it won't take any effect.

Here's the scenario: With the Terminal open I write

pico .profile

Then in the editor I enter

export JAVA_HOME="Library/Java/Home"
export PATH=$JAVA_HOME/bin:$PATH

Then I press ctrl+x to exit and y to save. I exit the terminal and when I open it up again and write

echo $JAVA_HOME

I only get an empty line. Can I edit the .profile in another way? I've tried every possible combination to set this variable but I keep getting an empty line. I have restarted the system several times with no luck at all.

share|improve this question

migrated from stackoverflow.com Oct 17 '11 at 16:10

This question came from our site for professional and enthusiast programmers.

1  
It sounds like the .profile file is not being used. Are you sure it is ~/.profile that is being modified? And the permissions are correct? (I am not sure what shell OS X uses by default, but here is the relevant section in bash.) –  pst Oct 14 '11 at 22:36
    
i just noticed that every time i save the .profile generates a new file every time i save and names it profile.save.2 and the number increases as i keep saving it. I don't think that's right. Any ideas? –  madcoderz Oct 14 '11 at 22:46
    
what is the output of: cat .profile ? –  Jochen Bedersdorfer Oct 14 '11 at 22:56
    
i wrote cat .profile and i got No such file or directory i'm i doing something wrong? –  madcoderz Oct 15 '11 at 4:35
    
By the way, this was working when i had Leopard as soon as i updated the operative system to OSX Lion the problem started happening. –  madcoderz Oct 15 '11 at 4:42

1 Answer 1

up vote 2 down vote accepted

I solved this problem by editing the ~/.bash_profile instead.

When you use pico .profile instead of editing the file, which will make a new file, I chose "read file" (I think it is ctrl=r) and it showed me a lot of files. From there I chose .bash_profile.

That was my solution. I don't know if it's the best solution but it worked for me.

share|improve this answer
    
If ~/.bash_profile exists, bash will not read ~/.profile. So whatever you write in there won't ever be parsed. –  slhck Oct 26 '11 at 20:52

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.