How can I find all installable versions with brew?

Suppose I have a component foo that has versions 2.1, 2.2, 2.2.1 and 3.0 available. Suppose I have installed version 2.1. How do I tell brew to get the latest version in the 2.x line but not 3.0?

Is there a way to list all available versions?

Is there a way to limit upgrade to the latest version of 2.x?

3 Answers

The latest version of homebrew gives an error Error: Unknown command: versions. This is because versions has been obsoleted from homebrew.

Instead, use brew search elasticsearch. This will give the available versions of elasticsearch.

Eg. elasticsearch ✔ elasticsearch@2.4

Then run brew install elasticsearch@2.4

You can check the final elasticsearch version by elasticsearch --version

2

Is there a way to limit upgrade to the latest version of 2.x?

I don't believe brew has a built-in way to specify the latest 2.x. You'd have to specify brew install foo@2.9. You could write a simple bash command using sort and grep to return it.

Is there a way to list all available versions?

To get the exact results without extraneous noise, you can use regex with brew search. It only returns foo and foo@___. This is especially helpful if you're searching for a short package name like r or git that would otherwise return a lot of noise.

$ brew search '/^foo$|^foo@/'

Note, brew search does seem to support Extended Regex, so I couldn't use the more efficient regex below. Of course, you could use a grep pipe to accomplish the same:

$ brew search foo | grep -E '^foo(@.*)?$'

Here is what I figured out (I use elasticsearch as example):

$ brew versions elasticsearch
1.3.2 git checkout 475debf /usr/local/Library/Formula/elasticsearch.rb
...
1.1.0 git checkout c7f653b /usr/local/Library/Formula/elasticsearch.rb
1.0.1 git checkout 9b8103f /usr/local/Library/Formula/elasticsearch.rb
1.0.0 git checkout 1fb5dda /usr/local/Library/Formula/elasticsearch.rb
0.90.11 git checkout 91c60b9 /usr/local/Library/Formula/elasticsearch.rb
0.90.10 git checkout b155496 /usr/local/Library/Formula/elasticsearch.rb
0.90.9 git checkout 28f45d0 /usr/local/Library/Formula/elasticsearch.rb
...
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like