4

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.

  • 2
    That echo command does not show PATH just the text in "" try echo $PATH and do you mean setenv rather than getenv – mmmmmm Nov 16 '15 at 13:29
  • Actually, I did a "launchctl getenv PATH" and "echo $(PATH)" within my makefile, and then copied/pasted the output, not noticing that make had already done the substitution and that the line-feeds between command and output got lost. Sorry. – Philip Keller Nov 17 '15 at 14:01
  • In the meantime, I also verified that the problem does not come from "make" : I replaced Eclipse's build command, which was a "make", with "printenv PATH", and the result is the same. Nor does it come from Eclipse: 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. I'm really beginning to think that "launchctl setenv" is accepted but ignored in El Capitan. – Philip Keller Nov 17 '15 at 14:01
  • The pointy of my comment is hat you are not showing us the actual path e.g. output from echo $PATH – mmmmmm Nov 17 '15 at 14:28
  • 1
    The command was: echo "PATH = $(PATH)" and the output was: PATH = /usr/bin:/bin:/usr/sbin:/sbin – Philip Keller Nov 17 '15 at 18:02
  • I'm going to put a hold on this. Could you edit the post to explain if you really need to just change the path - and if so, what apps need to read that change? It's looking like Apple is pushing users away from setting environment variables, so let's attack your problem that's to be solved rather than the "use an environment variable" to see if that gets you better answers... – bmike Dec 28 '15 at 18:06
  • Hi bmike. I think the thread is indeed moot; I have come to the conclusion that with El Capitan, Apple has quietly deep-sixed "launchctl setenv", and that there is no other way of setting global environment variables.

    What I was trying to do is to include the path for a cross-paltform gcc toolset, so Eclipse could find it. t

    – Philip Keller Dec 31 '15 at 16:27
  • My primary use for global environment variables was to include the path for a cross-paltform gcc toolset, so Eclipse could find it. The obvious work-around is to modify my Makefiles to use explicit pathnames for all the tools. This is a pain, but doable, and compatible with what I need when I run the same Makefile on Linux and Cygwin platforms. – Philip Keller Dec 31 '15 at 16:35

0 Answers0