If you use homebrew to manage packages in macOS, you might notice that some formulas come with several versions. Take elasticsearch for example,
$ brew search elasticsearch outputs two versions:
The one without version suffix tag is the current version (5.3.1 as of this writing). But what if you want to install 2.3.3 for example? as you might be working on a project with such requirement.
The good thing is, you can write your own formula, and install it like:
Better, you can just copy the original @2.3.3 formula from homebrew core git repository. See the current elasticsearch formula, which looks something like:
1 2 3 4 5 6 7 class Elasticsearch < Formula desc "Distributed search & analytics engine" homepage "https://www.elastic.co/products/elasticsearch" url "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.1.tar.gz" sha256 "1c277102bedf58d8e0f029b5eecc415260a4ad49442cf8265d6ed7adc0021269" # ... end
You need to modify the formula a little bit, to change its class name to add
AT233 (version) suffix:
1 class ElasticsearchAT233 < Formula
Then you can do:
If a formula also comes with a service,
brew services list will look like:
run the service by appending the version suffix:
See [email protected] formula for another example.