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.

I have OSX 10.8.2 with ZSH as my shell and iTerm as a terminal (don't know if the last thing is relevant). I have to mention that I'm relatively new to OSX.

I'm trying to set up some environment variables and I can't seem to figure out how.

I have two exports:

export GOBIN=$HOME/go/bin
export PATH=$PATH:$GOBIN

I tried changing: .bashrc, .bash_profile, .profile, .zprofile, .zshrc, ~/.MacOSX/environment.plist. (The last one I modified with Property list editor from xcode).

I don't understand WHY is this not working. What's the proper way to do this?

share|improve this question
1  
Did you open a new shell after you made the changes? Those files are only read at shell startup. –  James Thompson Feb 16 '13 at 20:44
    
New shell, restart, everything! –  Ilea Cristian Feb 16 '13 at 21:31
    
I'd try adding something like echo HI THERE to your .zshrc to verify it's being processed –  James Thompson Feb 16 '13 at 21:39

2 Answers 2

up vote 1 down vote accepted

OK, well, I can't answer right off the bat why it isn't working. You could give us some more detail. I also can't leave a comment due to lack of rep here (despite my rep on other stack exchange sites). So I'll at least try to make this an answer.

First of all, if you are in fact using zsh, ~/.profile, and all the bash rc files are irrelevant. Go ahead and focus on .zshrc. That will be the correct rc file the majority of the time for this kind of stuff.

This kind of stuff generally "just works", so I'm inclined to speculate there's some part of the process you're not understanding, or missing.

First of all, ensure you are, in fact, using zsh:

echo $SHELL
echo $0

Share this output, please.

Secondly, verify that things are, in fact, not working. You should have already posted the output of:

echo $PATH

Try this before and after running the export ... command. That's the only way to check that something else isn't going on.

A couple asides: restarts are irrelevant. If you put this stuff in your .zshrc, simply opening a new shell will suffice. Also, it might be easier to experiment by running these commands in an active shell, and not add them to your .zshrc file until you've resolved the issue.

Share the results of this and I'll get back to you.

share|improve this answer
    
I feel kind of sorry now that I see that I did something wrong, or forgot. I AM using zsh, but apparently the .zshrc was not saved properly when I left vim. Oopsie. Anyway, thanks! –  Ilea Cristian Feb 17 '13 at 20:31

That should work in ~/.zshenv or ~/.zshrc

If you have xcode you should also have dtrace which will let you see the files the system attempts to open as zsh executes which might help you track down what is happening

sudo dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }' -c zsh

Strangely I have a /etc/zshenv on my 10.7.5 but /etc/zshrc is what zsh attempts to load for the global config in that dtrace.

share|improve this answer

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.