MacOS – OS X Yosemite permanent environement variables

environment-variablesmacos

Since I upgraded to OS X Yosemite I do have massive problems with environment variables that I really, really NEED for development of some projects.

The Problems is:

Every time I install some kind of update from the app store and my macbook restarts in order to install it, it will delete all, but really all of my environment variables which then costs me nearly an hour to set it up again.

I've tried so many different solutions until now (I don't want to start listing them up here, I really searched the www for some hours…) and nothing has worked as permanent/persistent environment variable.

What I need to do:

  • System wide environment variables that are NEVER reset without my action. They have to be persistent/permanent!
  • Environment variables have to be readable by shell as well as GUI applications

I feel helpless and somehow stupid.
It's so easy on all linux distros I know and also in the Windows world. Why does it seem to be so hard for OS X?

Best Answer

have you tried adding them to your .bash_profile?

assuming you know how to use the vi editor:

  1. open terminal
  2. enter vi ~/.bash_profile
  3. add one line like the following for each environment variable you need to persist
    • export PS1='\[\033[34m\]\w\[\e[m\] ?? '
  4. Save the file.
  5. Restart your computer.

The only other thing would be to consider backing up your .bash_profile in case somehow you lose or corrupt it.