Best way to switch between @version and HEAD?

Good afternoon,

I have the need to test a package (Ansible in this case) at HEAD, but also need to use it regularly in Stable.

As the GitHub request to add a --stable flag was closed (which would actually make a lot of sense in a use case like this), I’m attempting to use brew switch to do this.

Currently, I’m attempting to use brew switch ansible 2.9.6_1 to switch to the Stable version, and brew switch ansible HEAD-e785bda_1 to switch to HEAD (as I’m waiting for a fix in Ansible_2.10, but it isn’t released yet).

Ideally, switching to HEAD might only require HEAD rather than the specific Git commit ID (though I do logically understand the reasons for this).

In the cases of simply installing HEAD, it would also be nice to get a flag added to install or switch that was --stable to switch back to the most recent stable version, or install the most recent version. If I installed Ansible via brew install --HEAD ansible, I would love to be able to reinstall stable perhaps by simple brew reinstall --stable ansible. Similarly, brew switch --stable or brew switch --head, etc.

Are there ways to accomplish this, as it stands today other than the “hit it with a hammer” method of unlink or uninstall?


Hi Michael,

Not sure if that fits your case but one possible way to work around the issue is to create a tap and maintain your own copy of the formula there under a different name (e. g. ansible-develop). The formula definition of ansible-develop can be copied from the original, you’d just remove the url and sha256 lines.

To switch versions, you would run:

$ brew uninstall ansible && brew reinstall ansible-develop

and vice versa.
If you want to keep both ansible and ansible-develop installed alongside each other and just switch between them, you can try:

$ brew unlink ansible && brew link ansible-develop

and vice versa.

One drawback would be that you’d be responsible for keeping your cloned formula in sync with the original. But it can be done with reasonable effort, I guess.