10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macの$PATHの設定箇所は「/etc/paths」にある

Last updated at Posted at 2018-07-18

:star: タイトルの通りですが、調べたことを以下に綴ります :star:

環境

macOS High Sierra (v10.13)
macOS Mojave (v10.14.1)

発端

~/.bash_profileが存在しなくても、$PATHが設定されていた。

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

調査

L1  $ cat /etc/profile
L2  if [ -x /usr/libexec/path_helper ]; then
L3  	eval `/usr/libexec/path_helper -s`
L4  fi
L5  
L6  if [ "${BASH-no}" != "no" ]; then
L7  	[ -r /etc/bashrc ] && . /etc/bashrc
L8  fi

L3の/usr/libexec/path_helper -sを見てみる

$ man path_helper
The path_helper utility reads the contents of the files in the directories /etc/paths.d and /etc/manpaths.d and appends their contents to
>> Google翻訳

path_helperユーティリティは、ディレクトリ/etc/paths.dおよび/etc/manpaths.dにあるファイルの内容を読み込み、その内容を次の場所に追加します。

結果

/etc/paths.d配下には何もないが、/etc/pathsに$PATHの設定があった!

$ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

参考になりました。

PATH設定がどこにあるか分からないときに見るべきファイル

10
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?