Mojave (10.14) setting environment variables

There are other questions and topics just like this but I can not find anything that is specific to 10.14 Mojave. I have tried the ~/Library/LaunchAgents/environment.plist method and I have tried to move the same file to /Library/LaunchDaemons (and restarted) but it does not affect Emacs when it is launched from the dock, Spotlight, or the Applications window.

In that file, I did launchctl setenv PATH $PATH:/usr/local/bin Curiously, when Terminal (bash) is launched and echo $PATH > /tmp/bash.debug is the first line in ~/.bash_profile, the output is /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin so... something has prepended /usr/local/bin while I was attempting to append it.

I have not tried things like /etc/launchd.conf or ~/.MacOSX/environment.plist because the pages I find say that both of those stopped working a while back.

In particular, I want to add /usr/local/bin to PATH. Currently, my work around is to do it in my Emacs start up files.

There was one person who mentioned that setting system wide environment variables in MacOS is a bad idea and I'm tempted to go along with that. The Emacs specific solution I have works and doesn't have any side effects. But, I'd like to know how to do it ... if it is possible. Once I get curious about something its hard for me to let it go.

As always, thank you very much for your time.


The answer to this one in Mojave is to create a named file in /etc/paths.d, for instance

vi /etc/paths.d/local_bin

Put

/usr/local/bin

in the file, save and quit. Start another terminal window and it will be on your path.

I have one for MacPorts

$ cat MacPorts 
/opt/local/bin