/usr/include vs /usr/local/include

homebrewsymlink

I just discovered that on my MAC /usr/local/include is a symbolic link to usr/include (since about 9 months), causing problems with homebrew.
I wonder whether this link is normal? harmless? Is there a way to disentangle that (make /usr/local/include an independent directory containing those files that belong there (which ones are that?) and keep the rest in /usr/include/)?

Best Answer

As you say it is a mess and there is no easy way to undo this as it is difficult to tell which ones were installed from which source.

The ones which should be in /usr/include come from OS X directly or Xcode and its command line tools.

So in theory you can identify which are Homebrew and which are not.

If you could then remove the /usr/local/include link mkdir a new /usr/local/include then mv the Homebrew items from /usr/include to the new dir. Then reinstall OS X and Xcode command line tools (the latter might be sufficient). However I think this is not going to be doable in practice. So delete the link and directory and reinstall OS X, Xcode command line tools and Homebrew.

If all your builds have /usr/local/include as the first include directory then you won't have any issues but that is ALL builds. (for example python builds that use C in setup should use the same includes python was built with so should use /usr/include)