How to depend on a specific version of a homebrew formula

homebrew

I'm having a conflict with a formula and a particular version of Boost. Ideally, since this is really just a build conflict (it's not using a Boost shared library), I'd like to automatically use a specific version when building. I doubt this is possible, so I'd really just be happy with it as a conflict or as dependency, but I can't find documentation for that. What I found is the generic dependency example:

class Foo < Formula
  depends_on "boost" => "with-icu"
end

Is this even something I can do?

Best Answer

Homebrew is still improving their support for depending on old versions of a library, with some planned improvements in this issue. In the meantime, you can use the homebrew/versions tap, which has formulae for boost 1.55 and boost 1.59. To depend on these versioned formulae, you could use the following:

depends_on "homebrew/versions/boost155"

or

depends_on "homebrew/versions/boost159"

EDIT:

You mentioned lack of documentation about conflicts. There is a conflicts_with keyword, but that is more about conflicts with being installed side-by-side. There's also a fails_with keyword, but that is related to specific versions of compilers. I think using depends_on with a formula from homebrew/versions will work best for you.