Я нашел виновника.Секретный соус был /usr/libexec/path_helper
, он выглядит в файле /etc/paths
и в каталоге /etc/paths.d/
.
Первые bash
исходники /etc/profile
, который выполняет следующий код:
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
# The above line is the secret sauce, so to say...
# First is adds default PATH values from the file /etc/paths
# Then all files in the /etc/paths.d/ directory are read and directories listed
# in each file (one per line) are appended to PATH
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
Далее bash
ищет ~/.bash_profile
, ~/.bash_login
и ~/.profile
.
Перечисляя эти шаги, PATH
построен следующим образом:
- Каталогив файле
/etc/paths
добавляются в PATH
- Каталоги, перечисленные в файлах в каталоге
/etc/paths.d/
, добавляются в PATH
- Обратите внимание, что они добавляются по сравнению сprepended. - Различные операторы
PATH={DIR_2_ADD}:"${PATH}"
в моих файлах ~/.bash_profile
и ~/.bashrc
prepend PATH