vorfee's Tech Blog

Just another tech blog

OS XのターミナルでPath設定が勝手に変わっているときに確認すること

結論

/etc/paths/etc/paths.dを確認する。

説明

OS Xでは/etc/profileでパスの設定を行っている。OS X El Capitanの/etc/profileの中身は、以下のようになっている。

# System-wide .profile for sh(1)

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

4行目の/usr/libexec/path_helper/etc/pathsを読み込み、変数pathに反映している。

したがって/etc/pathsの中を空にすれば勝手なことはされずに済む。 なお、/etc/pathsの中身はコメントアウトできないため、内容は削除する必要がある。