For various project-specific reasons, I have downgraded my boost (and boost-python) Homebrew installation to boost159 from boost (aka Boost 1.62.0 as of the writing of this question). The homebrew/versions/boost159 and boost-python159 formulas are keg-only and therefore I had to link them manually:
brew tap homebrew/versions
brew remove --force boost
brew remove --force boost-python
brew install boost159
brew link --force --overwrite boost159
brew install boost-python159
brew link --force --overwrite boost-python159
So far so good. But then, when I want to install some unrelated Homebrew formula that has a dependency on boost, Homebrew tries to brew install boost (Boost 1.62.0) and fails to link it:
[34m==>[0m [1mPouring boost-1.62.0.el_capitan.bottle.tar.gz[0m
[31mError:[0m The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/boost/accumulators/accumulators.hpp
Target /usr/local/include/boost/accumulators/accumulators.hpp
is a symlink belonging to boost159. You can unlink it:
brew unlink boost159
To force the link and overwrite all conflicting files:
brew link --overwrite boost
To list all files that would be deleted:
brew link --overwrite --dry-run boost
Possible conflicting files are:
/usr/local/include/boost/accumulators/accumulators.hpp -> /usr/local/Cellar/boost159/1.59.0/include/boost/accumulators/accumulators.hpp
[...]
Is there a way to make other formulas use boost159 instead of boost ? Please note that boost159 must be linked for other parts of the projects (not in my control) to work. That is, I can't leave it unlinked and set build variables instead.
PS. This is all taking place in a CI build actually, making the error much more disruptive.
References