I am looking to set environment variables for the use of some applications that are launched by icon or from the dock. I am aware of launchctl setenv for setting environment variables, but I am also aware that the effects of that last only until the next reboot.
I find various people posting hacks that come down to configuring some .zsh* initialization files, but those fines are not used until an interactive login session is started, and so are not of value for the case where the user does not happen to launch terminal
The particular environment variable of interest at the moment is JAVA_HOME for use by MATLAB . MATLAB is started by the shell script /Applications/MATLAB_R20xxx.app/bin/matlab and does not appear to have a .plist file associated with it . Editing the shell script would not be ideal.
There’s no general-purpose mechanism for you, as a user, to set environment variables on apps. Such a mechanism doesn’t really make sense on the Mac, because Mac apps aren’t supposed to rely on the Unix environment.
Of course, that stance breaks down when you start talking about developer tools. It’s not uncommon for developer tools to rely on environment variables. And because of that GUI developer tool will often provide a mechanism for setting environment variables. Xcode is a good example of this, where you can set environment variables for the app you’re debugging in the scheme editor.
It’s possible that your developer tool actually has similar support. I recommend that you ask that question via the vendor’s support channel.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"