0

I KNOW this question it's kind of a duplication, but I think my problem is a bit different than the other questions I found here.

If I echo $PATH, I can see the usual string with several paths. Ok. But I cannot find where they are really written (at least no all):

/private/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

/private/etc/paths:(there are some but not all I can see from the echo!!!)

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

~/.bash_profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

~/.bashrc

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

And I currently don't have any ~/.profile file.

I'm not a unix expert at all. I cannot understand where all the paths come from and so where's the best place to add or modify.

Can you suggest me something? :)

1 Answers1

1

Source Mastering the path_helper utility of MacOSX

Aimed to simplify path management, path_helper, the new tool introduced in Leopard that help manage the PATH environment variable, has probably not be as welcome as it should have been, particularly because it is not well documented. We try to shed some light on this obscure tool.

path_helper is located in /usr/libexec. By itself, this tool is harmless, since it does not change anything in your environment, it is just a bash or csh commands generator for constructing PATH and MANPATH environment variables based on some text files located in /etc. So, try it !

More then thousand words, lets run it:

$ /usr/libexec/path_helper
PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/apache-maven/apache-maven-2.0.9/bin"; export PATH
MANPATH="/usr/share/man:/usr/local/share/man:/usr/X11/man"; export MANPATH

The commands it output are not executed unless you call the same command in an eval like what it is done in the /etc/profile, which is the default startup script for bash shell:

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

But, how does it construct these paths ?

  • 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.
  • Files in these directories should contain one path element per line.

In your example /private/etc/profile you have:

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

Look in /etc/paths.d to see what path elements are being added from this file.

For more information see the man page

DavidPostill
  • 162,382