2

It is expected that shell environment variables won't be available in GUI apps launched via Spotlight or Finder.app.

But until Mavericks - I could launch an app via Command line such as:

open -a IntelliJ\ IDEA\ 11

And Intellij will inherit the environment variables defined in shell (In my case zsh). This does not seem to work properly anymore. I have seen similar problem, when I launch Emacs.app from command line.

Related thread - https://tex.stackexchange.com/questions/208181/why-did-my-tex-related-gui-program-stop-working-in-mac-os-x-yosemite

BTW, I know I can use Setting the system-wide PATH environment variable in Mavericks for setting system wide environment variables, but I don't want system wide environment variables. I want GUI app to inherit variables that were defined at the point, the app was launched from command line.

2

You can try something like this:

launchctl setenv VARIABLE VALUE
open -a IntelliJ\ IDEA\ 11
launchctl unsetenv VARIABLE

This will pass environment variable VARIABLE into the launched app and later it will be cleaned, but will remain in the app.

  • Doesn't work in El Capitan. :( – mgol Jan 20 '16 at 13:02

You must log in to answer this question.

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