2

Possible Duplicate:
What are PATH and other environment variables, and how can I set or use them?

How to set an environment variable in Mac OS 10.6. I am finding it difficult or the options that I found in the google searches does not seem to work as expected

1
  • Another approach that works for GUI applications and remains permanent is described here. Sep 19, 2012 at 16:22

3 Answers 3

5

Aside from the standard *nix ways of exporting variables (see JRobert's answer) there is a Mac specific way, which might be helpful, especially if you want GUI programs to pick up the environment variables.

First install the Developer Tools (on your OS X DVDs). Then in Terminal:

open ~/.MacOSX/environment.plist

The file should just have an example key:value pair for PATH. Then just click on "Add Child" and make your changes. You might have to log out and back in again, I'm not certain if the file gets reloaded on the fly.

The benefit of the environment.plist is that it's available to the entire OS, rather than just command line programs.

3
  • See this page for a demonstration.
    – fideli
    Aug 30, 2010 at 14:25
  • @fideli, thanks for that link. The plist had already been created on my installation, I didn't think to check if it existed by default.
    – redacted
    Aug 30, 2010 at 15:57
  • I don't think this is the correct way, nor the Mac specific way of setting system-wide environment variables. There are multiple levels of setting environment variables and even more if you have multiple shells installed. If, for instance, you're using zsh then there's a .zprofile for the user, .zsh for the shell, etc. It's a huge mess! You shouldn't have to edit .plist files to,make such changes.
    – user148298
    Dec 10, 2022 at 6:55
1

An example:

export PATH=/opt/local/bin:$PATH

1

In your .bashrc:

export variable='value'

If you aren't using bash or this isn't what you meant, make your question more specific. What have you tried? What did you expect to see? What did you actually see? What are you trying to accomplish. Help us help you.

Not the answer you're looking for? Browse other questions tagged .