The Internet has documented several ways of installing a specific version of a piece of software using Homebrew. None of them seem to work anymore. It seems like a feature that the developers of Homebrew do not want to support fully or at all.
A way of installing a specific version is by executing the following commands. The following assumes that we want to install version 3.24.0 of a package named foo.
Start by creating a new tap. The tap can contain multiple formula so we name it something generic.
brew tap-new simonbs/extracted
Then extract the formula into the local tap.
brew extract foo simonbs/extracted --version 3.24.0
Finally, install the package.
brew install simonbs/extracted/[email protected]