Confused about how to work with @version formula

(Andrew Havens) #1

I’m trying to understand the correct workflow for installing and managing older versions. For example, I need to upgrade to a newer version of PostgreSQL, but not the latest version. The last time I did brew install postgresql, the latest version was 9.5.3. However, now if I do brew upgrade postgresql, the latest version would be 10.1, so that approach is not going to work. Reviewing the history of the postgresql formula, I see that the latest 9.5.x version was 9.5.5 before it jumped to 9.6.1. Ideally, I’d like to install 9.5.9.

I see that there is a postgresql@9.5 formula. The latest version supported by this formula is 9.5.10. I’ve read all the documentation that I could find regarding these @version formula, but it’s still not clear to me how to use them correctly. When I install via brew install postgresql@9.5 I see that it is keg-only, and the paths include the @9.5 in them. If I try to do brew switch postgresql 9.5.10, it says that I don’t have that version available (under the postgresql formula name).

I don’t really need or want to support multiple versions of PostgreSQL. I have an existing database that I want to use and want to continue to connect to it via the default port. I just want to “pin” my default version of PostgreSQL to 9.5.9, or alternatively at the latest version within the 9.5.x branch.

Is there a way to do this? What is the correct way to work with these @version formulae?

(Andrew Havens) #2

I love Homebrew! You people do great work supporting our community and we love you for it! Any thoughts on how to correctly handle this scenario?

(Mike McQuaid) #3

Just use brew install postgresql@9.5 and don’t use brew switch but brew link if you want it linked.

(Ron Arts) #4

Right, and brew link now throws a confusing message:

Warning: postgresql@9.4 is keg-only and must be linked with --force 
Note that doing so can interfere with building software.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/postgresql@9.4/bin:$PATH"' >> ~/.bash_profile

So it’s not as easy as ‘Just use…’