None of the paths I have in the /etc/paths.d directory are being added to $PATH in any of the shells on my High Sierra system. Presumably there’s supposed to be something in some file that says to look in /etc/paths.d when a shell starts; what is that something and where should it be?

Ideally I’d like to know a proper way (i.e. not some weird hack that technically solves the problem but will cause more problems down the line, because that’s almost certainly how I got into this mess) to get $PATH to use the contents of /etc/paths.d for at least bash and zsh.

  • Which shell are you actually using, which shell profiles (.bashrc etc.) have you created? – nohillside Nov 18 '20 at 6:58
  • Out of curiosity, why do you need to add /etc/paths.d to PATH? PATH is used by the shell to find executables, and there shouldn't be any in /etc or its subfolders. – jaume Nov 18 '20 at 6:59
  • 1
    @jaume Adding entries (files) to /etc/paths.d is an easy way to add path elements systemwide without tampering with /etc/profile or /etc/paths. – nohillside Nov 18 '20 at 7:00
  • @nohillside I have .zshenv, .bash_profile, and .bashrc. I didn’t create any of those, though I have had to mess with them after various install scripts had their way. I use bash more often than zsh. – Gregory Gan Nov 18 '20 at 7:29
  • /etc/profile gets executed automatically, so maybe one of the . profiles overwrites PATH for good. – nohillside Nov 18 '20 at 7:42

/usr/libexec/path_helper is used to build PATH from the default in /etc/paths and the entries in /etc/paths.d (see man path_helper for details). By default this is called in /etc/profile which is executed for each sh/bash/zsh style login shell.

On my system /etc/profile looks like this

# System-wide .profile for sh(1) and friends

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
  • That first if was what I needed. Thanks! – Gregory Gan Nov 18 '20 at 7:26

You must log in to answer this question.

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