1

I have both ~/.bash_profile & ~/.profile files.

~/.bash_profile contains one line:

export PATH=/Applications/mamp/bin/php5.5.3/bin:$PATH

~/.profile contains three lines:

# MacPorts Installer addition on 2014-02-02_at_20:54:53: adding an appropriate PATH variable for use with MacPorts.
export PATH=/Applications/MAMP/bin/php5.5.3/bin/:/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

As you can see I am trying to get my default PHP PATH to use MAMPs PHP because I have mcrypt installed on it. For some reason when I type whereis PHP I get the native route: /usr/bin/php, and when I echo $PATH I get:

/Applications/mamp/bin/php5.5.3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Somewhere I have another file thats really controlling my PATH and I have no clue where it is. What else could be controlling my PATH route?

NOTE: I have Homebrew, MacPorts, Xcode, and Xcode Command-Line Tools installed.

4

2 回答 2

1

您所看到的来自系统范围的 /etc/paths 文件。它是 ~/.profile、~/.bash_profile 和其他人参与之前的基本 $PATH 环境变量的来源。如果您在终端窗口中,则可以使用以下命令对其进行编辑:

sudo open -t /etc/paths

默认情况下,它包含以下路径:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

但是,我不建议编辑此文件,因为它是系统范围的,并且会影响系统上的每个用户。

如果您想完全控制 $PATH,以便只影响您自己的帐户,您最好不要在 .profile 的导出 PATH 行中包含 $PATH。例如(但不是这个):

export PATH=/Applications/mamp/bin/php5.5.3/bin:/opt/local/bin:/opt/local/sbin
于 2014-03-26T12:10:30.780 回答
0

你确定.profile正在加载?尝试测试并为其添加一条回声线:

echo "test: .profile has loaded"

现在打开一个新的终端窗口,你看到你的回声了吗?我怀疑不是,因为我认为 OSX.profile默认不会加载,至少今天是这样。

如果你真的想使用.profile你可以要求.bash_profile加载它:

if [ -f ~/.profile ]; then
    source ~/.profile
fi

希望这可以帮助。

编辑:看起来 .profile 已加载,如果没有 .bash_profile 或 .bash_login 存在此答案中的建议

于 2014-02-07T19:16:11.547 回答