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.

NikiC
  • 100,734
  • 37
  • 191
  • 225

2 Answers2

1

What you're seeing is coming from the system-wide /etc/paths file. It is the source of the base $PATH environment variable before ~/.profile, ~/.bash_profile and others get involved. If you're in a Terminal window, you can edit it with the following command:

sudo open -t /etc/paths

By default it contains the following paths:

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

I wouldn't recommend editing this file, however, because it is system-wide and will affect every user on the system.

If you want complete control over $PATH, so as to affect only your own account you're probably better off just not including $PATH in your .profile's export PATH lines. For example (but not this):

export PATH=/Applications/mamp/bin/php5.5.3/bin:/opt/local/bin:/opt/local/sbin
AlwaysLearning
  • 7,915
  • 5
  • 27
  • 35
0

Are you sure .profile is being loaded? Try a test and add an echo line to it:

echo "test: .profile has loaded"

Now open a new terminal window, do you see your echo? I suspect not as I don't think OSX loads .profile by default, at least today.

If you really want to use .profile you can ask .bash_profile to load it:

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

Hope this helps.

Edit: Looks like .profile is loaded, if no .bash_profile or .bash_login exist as suggested in this answer

Community
  • 1
  • 1
mmoser
  • 3
  • 4