How to avoid MacPorts conflict with /usr/local

2

Since MacPorts is not compatible with /usr/local *, whenever I install/update ports with MacPorts I would

sudo mv /usr/local /usr/local.bak

and after I am done building MacPorts stuff

sudo mv /usr/local.bak /usr/local

This works and solves a lot of the previous mysterious build errors. However it is very cumbersome and sometimes I don't remember to do this, either the "before" step or the "after" step, and have to fix it afterward.

Is there a better way to avoid this conflict?

EDIT * see these links for examples/suggestions of temporarily moving /usr/local as a solution to MacPort build problems.

https://stackoverflow.com/questions/1827377/install-git-core-svn-fails-with-macport

https://trac.macports.org/ticket/21649

https://trac.macports.org/ticket/29998

ceiling cat

Posted 2011-08-30T23:25:04.087

Reputation: 3 557

Answers

2

I don't understand what /usr/local conflicts you're talking about. MacPorts intentionally uses its own /opt hierarchy in order to avoid conflicting with anything you already had in /usr/local. It shouldn't be putting anything in /usr/local unless perhaps you changed its configuration.

Were you thinking of Homebrew? I believe Homebrew still puts things in /usr/local by default, whereas MacPorts uses /opt and Fink uses /sw.

So I guess my "better way to avoid this conflict" is to use MacPorts instead of Homebrew, and leave MacPorts set to its default prefix of /opt.

Spiff

Posted 2011-08-30T23:25:04.087

Reputation: 84 656

I am using MacPorts; and I don't have Homebrew. Please see the edit for why I am doing this.

I am curious why you don't have this issue though. I have checked my path and it points to /opt/local/bin:/opt/local/sbin:/opt/subversion/bin: before anything from /usr/local. But this is still an issue. – ceiling cat – 2011-08-31T08:12:33.937

1MacPorts cannot isolate itself away from /usr/local, as this path is in the default search path of the compiler and cannot be removed. – raimue – 2011-09-23T15:16:42.353