So, this thread Use `/etc/paths` or `/etc/paths.d` to add items to the PATH in macOS Sierra? discusses /etc/paths and /etc/paths.d briefly in connection with macOS (ne OS X 12, sierra) /usr/libexec/path_helper, which helpfully puts /usr/bin:/bin:/usr/sbin:/sbin (the contents of /etc/paths, one per line) at the start of your PATH.

I understand the intent (along with the intent behind SIP), but what if one actually does know what one is doing and actually does want to have executables in one's own ~/bin (for example) that supercede the executable with the same name that Apple, in its unlimited beneficence, has modified or limited in one of its many unhelpful ways. Or, perhaps, wants /opt/... versions to be found before Apple's defaults. (If one wants to run a windowed version of emacs, for example.)

I'm willing to use this mechanism. My understanding is that I will need to disable SIP before I can modify /etc/paths.d/ but does anyone know if it is possible to put a file (00LookHereFirst, say) in /etc/paths.d/ that will prepend even those in /etc/paths? (OW, of course, modify /etc/paths. But I am trying to play nice. And, of course, it will be trashed if I ever let them harass me into downgrading to a newer release.)

Answers of the form "If you want to be treated like a grown-up stick to BSD" would not be considered helpful.

(Sorry for the tags. They're as close as I can come with my limited powers.)

  • I looked for something like this a few months ago, found nothing, and decided to use /etc/profile instead (which calls path_helper in the first place).
    – muru
    Jun 7 '17 at 3:45
  • 1
    You can modify both /etc/paths.d and /etc/paths with SIP enabled. I'm not sure what you mean in that section. Jun 7 '17 at 3:51

To answer my own question: directories in /etc/paths are added, in order of occurence in the file before any of the directories in files in /etc/paths.d. directories in 00Whatever are included before any of those in files that do not start with 00

It is not clear to me, yet, how modifications to PATH in the user's own start-up files are incorporated into the path-helper mechanism (if at all). path-helper is invoked in /etc/profile which traditionally is evaluated before the $HOME/.[whatever] (It seems to be only .bash_profile in my case, but then I am running bash. There was a time when the intended distinction between .bash_profile and .bashrc was respected. Times were good.) Nevertheless, path-helper is invoked after the $HOME intialization file[s] are evaluated.

I apologize for asking the question, when it was so easy to answer. I had assumed that because /etc is restricted the tree under it would be, and thus I would have to boot from the recovery partition in order to check. As I am at the tail end (I hope) of a long process of migrating from 10.aLongTimeAgo to 10.12.5 and I did not want to reboot yet. But /etc is a link, and as near as I can tell none of the files in the /etc/ tree are restricted.

Commentary: Putting /etc/ports before everything else is coercive and unwelcome. If Apple is serious about structuring the generation of PATH, and I am happy to see that happen, then what they put in /etc/paths should go in /etc/paths.d/00SystemDefault or some such. In which case one could override it with /etc/paths.d/000ScrewYourDefaults and still be playing nice.

Thanks for your forbearance

Not the answer you're looking for? Browse other questions tagged or ask your own question.