Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I prevent macports from taking over my PATH? I still want to have the installed software show up, but I want things in the standard system paths (/bin, /sbin, /usr/bin, ...) to have precedence over anything that macports installs.

share|improve this question
You might consider accepting an answer so that people can get points … – Nerdling Oct 21 '09 at 13:18

MacPorts Installer automatically modifies the environment so that MacPorts commands are called before system commands in its Postflight Script. You can type env in the terminal to see what your PATH is currently. If your ~/.profile was modified, you can manually change it back from:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH


export PATH=$PATH:/opt/local/bin:/opt/local/sbin

You must restart the terminal for this to take effect.

If this isn't the problem, check the environment.plist with the Property List Editor:

share|improve this answer
My ~/.profle was modified by macports, there was even a comment in there telling me so. I commented out the PATH append in there and now my PATH is back to how it used to be. I'm on OSX 10.8 if it helps anyone. Thanks again hanleyp. – user217874 Apr 17 '13 at 20:10

You probably have line in your .bashrc or .profile that sources /opt/local/share/macports/setupenv.bash

You will have to remove that and setup your PATH (and MAN_PATH) yourself. You can use the macports file as a guide, just switch

export PATH="${binpath}${sbinpath}${PATH}"


export PATH="${PATH}${binpath}${sbinpath}"

share|improve this answer
i don't have a Mac so maybe it's different, but don't you need separators between the variables in your export statements? eg "export PATH=${PATH}**:**${binpath}**:**${sbinpath}" – quack quixote Oct 6 '09 at 14:29
asterisks for emphasizing the colons, naturally... – quack quixote Oct 6 '09 at 14:30
Yes, you do. This is part of a larger script that adds the necessary colons to ${binpath} and ${sbinpath} – KeithB Oct 7 '09 at 11:56

I know it's been a while since the question was asked, but for the benefit of everyone else who finds this page:

On my system, Macports modified ~/.bash_login to insert its insidious $PATH modification command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.