Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
956 views
in Technique[技术] by (71.8m points)

macos - Is there a problem with having /usr/local/bin before /usr/bin on the path in OS X?

By default, OS X 10.6 uses /usr/libexec/path_helper to add the following paths listed in the file /etc/paths:

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

This means that /usr/bin comes before /usr/local/bin on the path. This results in the version of git installed by Xcode 4 in /usr/bin to be called instead of the version installed by Homebrew into /usr/local/bin.

Which leads me to my question, is there a problem with having /usr/local/bin come before /usr/bin in the path? Is there a specific reason that Apple defaults to having /usr/bin come before /usr/local/bin?

How to change order of /usr/bin and /usr/local/bin

Is it a problem to move /usr/local/bin from the bottom of the file /etc/paths to the top? Doing so would impact the path for more than just when I fire up Terminal, since /usr/libexec/path_helper could be used by other resources (I'm uncertain about this).

While redundant, it seems safer for me to add /usr/local/bin to the path in ~/.bash_profile, which would mean that /usr/local/bin would be on the path twice.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

No, and no. They're just weird ... local by definition should override.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...