Mac OS X 10.9 - setting permanent environment variables

≯℡__Kan透↙ 提交于 2019-11-27 18:27:28

Drop the $(...) bit, which would attempt to execute the command within the brackets and set $MULE_HOME to whatever it produces. In your case /opt/mule-standalone-3.4.0 is not an executable, hence the error you are getting.

export MULE_HOME=/opt/mule-standalone-3.4.0

and use ~/.bashrc not ~/.bash_profile.

EDIT: It seems opinion is that you should set environment variables in your ~/.bash_profile script, and not ~/.bashrc script.

CodeOverRide

Just did this really easy and quick. First create a ~/.bash_profile from terminal:

touch ~/.bash_profile

then

open -a TextEdit.app ~/.bash_profile

add

export TOMCAT_HOME=/Library/Tomcat/Home

Save document in TextEdit and you are done.

Alternatively, you can also add the following command to your .bash_profile if you want your environment variables to be visible by graphic applications. In Mac OS X, graphic applications do not inherit your .bash_profile config :

launchctl setenv MYPATH myvar

You can put your export statement in ~/.bashrc

It seems that Apple keeps changing how to do this. And it's all about context. One way does not necessarily work when another does. I needed it to work in an IDE, and neither of the bash files mention here (Linux style) did that. The current way for GUI apps to respect this on a permanent basis is SUPER convoluted compared to Windows and Linux!

In a nutshell, you have write a huge pile of ugly XML into a plist file to run some bash. That goes into your "launch agents" directory, i.e. ~/Library/LaunchAgents/my.startup.plist. Here's another Stack Exchange thread on the subject:

https://apple.stackexchange.com/questions/106355/setting-the-system-wide-path-environment-variable-in-mavericks

That gives you a full copy & paste which you can tweak to set your specific variable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!