3

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.

5
  • Which shell are you actually using, which shell profiles (.bashrc etc.) have you created? Commented Nov 18, 2020 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. Commented Nov 18, 2020 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. Commented Nov 18, 2020 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. Commented Nov 18, 2020 at 7:29
  • /etc/profile gets executed automatically, so maybe one of the . profiles overwrites PATH for good. Commented Nov 18, 2020 at 7:42

1 Answer 1

3

/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` fi if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi 
1
  • That first if was what I needed. Thanks! Commented Nov 18, 2020 at 7:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.