Setting Environment Variables for Mac OS X Programs

For the most part, Mac OS X programs do not use environment variables or the PATH. They behave in a very different way from other Unix environments on this score. However, as Java developer I use several tools that require that other command line programs be available on the system PATH. In Windows and Unix there are well known places to put this kind of information but in Mac OS X the location for these changes is obscure.

Adding the variables to the /etc/profile, /etc/bashrc, ~/.profile, or ~/.bashrc files does not accomplish the task since these files are not used to setup the environment of the WindowServer process, the parent of all Mac OS X programs. I did, eventually, find some information on the subject.

There are these articles: Environment Variables, QA1255 and QA1068.

These articles were really hard for me to find, I think, because they were written mostly for folks wanting to port Unix applications to Mac OS X. In my case, I am attempting to use Java applications like Eclipse and Netbeans. Specifically, they needed the subversion commands on the path and they were installed into /usr/local/bin instead of /usr/bin. A good policy but not on the default PATH variable.

NOTE: I forgot to mention, you have to logout for these changes to have any effect.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Shell environment variables for user www

Where is /etc/launchd.conf on Mac OS X Leopard. Im going crazy trying to figure out how to set environment variables for user "www" which is the user apache runs as. This process runs automatically on a server reboot so what user would I want to modify the environment.plist for. User www has no home directory. Or if I need to modify a profile file where is www's profile?

Thanks to anybody who can help me find answers

/etc/launchd.conf may not

/etc/launchd.conf may not exist. On default installs it does not. You can create it, however, and it will take effect on your next reboot.

/etc/launchd.conf

You were close with /etc/profile, and environment.plist will _nearly_ work, but the parent of all processes on Mac OS X is launchd, not WindowServer. So the file you want to make a truly global (system-wide) change is /etc/launchd.conf.

Have a look at http://www.digitaledgesw.com/node/31 if you're interested in my full writeup on this.

Again, thanks for this

Again, thanks for this information. I recently needed to set another environment variable and I realized that while this is good for environment variables that are set for every user, it is still best to use environment.plist for environment variables that may need to be different or not set at all for other users.

Thanks for this!

Thanks for this!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.