I'm using HomeBrew for my usual mac stuff but I need to do some experiments with other package managers. So I installed MacPorts. everything seems alright but brew doctor asks me to move it:

warning: You have MacPorts or Fink installed:

This can cause trouble. You don't have to uninstall them, but you may want to

temporarily move them out of the way, e.g. sudo mv /opt/local ~/macports

So I listened and moved it. And then in my bash profile I changed

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


export PATH="~/macports/bin:~/macports/sbin:$PATH"

and now when I when run port ... it gives me this error:

-bash: /Users/foobar/macports/bin/port: /opt/local/libexec/macports/bin/tclsh8.5: bad interpreter: No such file or directory

What am I doing wrong and how can I solve it?


I edited the /Users/foobar/macports/bin/port file as the admin and edited the first line from #!/opt/local/libexec/macports/bin/tclsh8.5



now I get this new error:

sources_conf must be set in /opt/local/etc/macports/macports.conf or in your /Users/foobar/.macports/macports.conf file while executing "mportinit ui_options global_options global_variations" Error: /Users/foobar/macports/bin/port: Failed to initialize MacPorts, sources_conf must be set in /opt/local/etc/macports/macports.conf or in your /Users/foobar/.macports/macports.conf file


changed all the /opt/locals to ~/macportss in




nothing changed!


I see some of the guys here try to guid me towards removing/uninstalling MacPorts or HomeBrew. That's not what I'm asking for. I am able to revert all I did and make the MacPorts work again (in fact I just did that). My question is why HomeBrew Is saying that? what I happens If I don't do what it is asking for? What if I want the MacPorts too? and most importantly how make the MacPorts keep working after moving?

  • can you update your question with the output of which port?
    – Scottmeup
    Commented Jul 8, 2018 at 21:05
  • 2
    The whole point of moving macports out of the way is to remove macports from the path so wither move macports or edit the PATH not both. I would ask why do you have both macports and homebrew?
    – mmmmmm
    Commented Jul 8, 2018 at 21:07
  • @Scottmeup no output!
    – Foad
    Commented Jul 8, 2018 at 21:14
  • 1
    Then debug it yourself - both macports and homebrew developers say it does not work = or at least it is not worth their time to debug any issues.
    – mmmmmm
    Commented Jul 8, 2018 at 21:49
  • 1
    Homebrew and MacPorts don't necessarily have the same software. I have both and have experienced no problems. There are cases where I needed one or the other to load a particular software package.
    – Natsfan
    Commented Jul 8, 2018 at 22:47

3 Answers 3


Disentangling messed up dot files and environment variables and paths might be a lot of work if you didn’t follow the recommended steps precisely or made subsequent changes. What about making a list of the homebrew packages you have (if any) then removing it entirely. Same with macports - don’t try to adapt it to run in a new place - remove it entirely after you know what packages you need.

Then make a brand new user account - install homebrew there cleanly with a default path and having cleaned up /opt before you made the new account.

This will quickly let you know if you have a system problem or it’s just the weight of all the changes made to get the previous software to run.

The alternative to this will be a lot of back and forth and you dumping a ton of data into the question or arranging remote access with someone skilled in picking apart bash/scripting errors and digging into the code and what brew doctor has to say about your setup that’s broken.

-bash: /Users/foobar/macports/bin/port: /opt/local/libexec/macports/bin/tclsh8.5: bad interpreter: No such file or directory

That's your problem right there. While you moved macports, and updated your path, you did not also change all the internal references to the original path.

I looked in that file and found a reference to:


In general, any unix package larger than a single file can NOT be moved to any random location in the filesystem. It will WORK from any random location but only if you build it there.

When you installed the first program that used the tcl library it got compiled/linked to the full path of that library, along with stuff in /usr/lib and more stuff in /System/Library/Frameworks. Move any of those and a lot of stuff won't run anymore.

So, your choices are:

  • Move MacPorts and reinstall everything
  • Move homebrew and reinstall everything

Why did homebrew break macports? They wanted to use the same path, something was already there, and it's not their job to deal with someone else's process.

They should have done 10 seconds more research and found a better way, like a non-conflicting path.

  • Thanks for the informative answer. So it seems the location of macports is hard coded in the binary files and I can't hack it through. I moved everything back and reverted the edits on the files. Now macports just works fine but bre doctor keeps complaining.
    – Foad
    Commented Jul 10, 2018 at 13:18

Navigate to the directory /Users/foobar/macports/var/macports/registry :

cd /Users/foobar/macports/var/macports/registry

Now query the registry database for installed programs and create a file with all your macports installed programs on your desktop.

sqlite3 registry.db 'select name, requested from ports' | cut -d'|' -f1 > ~/Desktop/macports.txt

Now remove /Users/foobar/macports then follow the uninstall instructions in the MacPorts guide. At this point decide whether to reinstall MacPorts and remove HomeBrew or just use HomeBrew.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .