Setting system-wide environment variables in El Capitan

I was using the method described in this post to invoke "

launchctl setenv
" to set environment variables globally. I have just upgraded to OS X 10.11 "El Capitan," and now I see that the launchctl command works fine, but appears to have no effect on the actual environment. For example, here is the output from some debug code I stuck into a "make" file running under Eclipse:


launchctl getenv PATH

/usr/bin:/bin:/usr/sbin:/sbin:/opt/ecos/gnutools/h8300-elf/bin:/opt/ecos/gnutool s/arm-elf/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin


echo "PATH = /usr/bin:/bin:/usr/sbin:/sbin"

PATH = /usr/bin:/bin:/usr/sbin:/sbin


Anyone have any idea what's happening to me? Thanks in advance.


Important note 1: I'm talking about system-wide environment variables, not environment variables within a shell.

Important note 2: This problem is specific to El Capitan; I had it working fine (again...) in Yosemite.

iMac, OS X El Capitan (10.11.1)

Posted on Nov 16, 2015 5:10 AM

Reply
4 replies

Nov 16, 2015 8:09 AM in response to Linc Davis

No, "make" is not the culprit: I replaced Eclipse's build command, which was a "make", with "printenv PATH", and the result is "/usr/bin:/bin:/usr/sbin:/sbin". If anything, the guilty party would be Eclipse, but I've been working with this version of Eclipse for years, and it's never reset the path on me before.


Besides, I wrote a quick command-line program in Xcode to do a getenv("PATH"), and ran it within the debugger. It showed that the path was modified by Xcode, but it didn't include my modifications that I had applied via launchctl.


Of course you're right about the PATH variable only affecting the shell. Specifically, the shells spawned by "make" when it goes to compile – it doesn't find my cross-compiler.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Setting system-wide environment variables in El Capitan

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.