LoginSignup
70
69

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-07-09

背景

brew doctor したら過去にインストールしたPalmSDKが残ってるぞと言われた。気にしなくていいよと書かれてはいるが気持ち悪いので削除したい。

Warning: Some directories in your path end in a slash.
Directories in your path should not end in a slash. This can break other
doctor checks. The following directories should be edited:
    /opt/PalmSDK/0.1/bin/

PATH設定箇所の捜索

どこにも設定していない。

以下をみても、grepしてみても、どこにもそんなの書いてない...。

/etc/bashrc
~/.bash_profile
~/.bashrc
~/.profile

どこだ?

/etc/profileに設定がありました。

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

で、この /usr/libexec/path_helper を実行してみると、以下のものが出力されます。

$ /usr/libexec/path_helper -s
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:
/opt/X11/bin:/opt/PalmPDK/bin:/opt/PalmSDK/0.1/bin/";
export PATH;

どうやら$PATHの設定を行ってくれる実行ファイルらしい。でもどこを見てるんだ?

path_helper

man path_helper を実行してみると答えが書いてありました。

path_helper(8)            BSD System Manager's Manual           path_helper(8)

NAME
     path_helper -- helper for constructing PATH environment variable

SYNOPSIS
     path_helper [-c | -s]

DESCRIPTION
     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 the PATH and
     MANPATH environment variables respectively.  (The MANPATH environment vari-
     able will not be modified unless it is already set in the environment.)

     Files in these directories should contain one path element per line.

     Prior to reading these directories, default PATH and MANPATH values are
     obtained from the files /etc/paths and /etc/manpaths respectively.

     Options:

     -c      Generate C-shell commands on stdout.  This is the default if SHELL
             ends with "csh".

     -s      Generate Bourne shell commands on stdout.  This is the default if
             SHELL does not end with "csh".

NOTE
     The path_helper utility should not be invoked directly.  It is intended
     only for use by the shell profile.

Mac OS X                        March 15, 2007                        Mac OS X

なるほど、/etc/paths.d/etc/manpaths.d の中身が$PATHに足されるのね。

/etc/paths.d

ls /etc/paths.d/ とすると、以下が出てきたーっ!

$ ls /etc/paths.d/
40-XQuartz
PalmPdkPath
PalmSdkPath  

まんま書いてあるのですね。

/etc/paths.d/PalmSdkPath
/opt/PalmSDK/0.1/bin/

対応実施

すでにSDK削除済みなのでパスの設定も削除して対応

$ sudo rm /etc/paths.d/PalmPdkPath
$ sudo rm /etc/paths.d/PalmSdkPath

反映タイミング

ターミナル起動時に設定が反映されます。

70
69
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
70
69