What is the proper way to modify environment variables like PATH in OS X?
I've looked on Google a little bit and found three different files to edit:
- /etc/paths
- ~/.profile
- ~/.tcshrc
I don't even have some of these files, and I'm pretty sure that .tcshrc is wrong, since OS X uses bash now. Where are these variables, especially PATH, defined?
I'm running OS X v10.5 (Leopard).
Best Answer
Bruno is right on track. I've done extensive research and if you want to set variables that are available in all GUI applications, your only option is
/etc/launchd.conf
.Please note that environment.plist does not work for applications launched via Spotlight. This is documented by Steve Sexton here.
Open a terminal prompt
Type
sudo vi /etc/launchd.conf
(note: this file might not yet exist)Put contents like the following into the file
Save your changes in vi and reboot your Mac. Or use the
grep
/xargs
command which is shown in the code comment above.Prove that your variables are working by opening a Terminal window and typing
export
and you should see your new variables. These will also be available in IntelliJ IDEA and other GUI applications you launch via Spotlight.