Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I brew link a specific version?

Tags:

homebrew

People also ask

How do I install a specific version of a package with brew?

Installing the latest package: Easy Installing with brew can't be made any simpler. Search the package you need, type brew install <package-name> , and that's all.

How do I install a specific version of Swiftlint?

Just go to Swiftlint release page and select the appropriate version. Download it and extract it. You should be able to see an executable and a licence txt file.


DEPRECATED in Homebrew 2.6.0 (December 2020). Check the other answers for updates

The usage info:

Usage: brew switch <formula> <version>

Example:

brew switch mysql 5.5.29

You can find the versions installed on your system with info.

brew info mysql

And to see the available versions to install, you can provide a dud version number, as brew will helpfully respond with the available version numbers:

brew switch mysql 0

Update (15.10.2014):

The brew versions command has been removed from brew, but, if you do wish to use this command first run brew tap homebrew/boneyard.

The recommended way to install an old version is to install from the homebrew/versions repo as follows:

$ brew tap homebrew/versions
$ brew install mysql55

For detailed info on all the ways to install an older version of a formula read this answer.


Sadly brew switch is deprecated in Homebrew 2.6.0 (December 2020)

$ brew switch
Error: Unknown command: switch

TLDR, to switch to package version 10:

brew unlink package
brew link package@10

To use another version of a package, for example node:

  • First, ensure that the specific version is installed using brew list. My package here is node (16) and node@14.
➜  ~ brew list
==> Formulae
node
node@14

➜  ~ node -v
v16.1.0
  • Unlink the current package: brew unlink node.
➜  ~ brew unlink node
Unlinking /usr/local/Cellar/node/16.1.0... 7 symlinks removed.
  • Link the correct version
➜  ~ brew link node@14
Linking /usr/local/Cellar/node@14/14.16.1_1... 3857 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/node@14/bin:$PATH"' >> ~/.zshrc
➜  ~ node -v
v14.16.1

I asked in #machomebrew and learned that you can switch between versions using brew switch.

$ brew switch libfoo mycopy 

to get version mycopy of libfoo.


If you have installed, for example, php 5.4 it could be switched in the following way to php 5.5:

$ php --version
PHP 5.4.32 (cli) (built: Aug 26 2014 15:14:01) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

$ brew unlink php54

$ brew switch php55 5.5.16

$ php --version
PHP 5.5.16 (cli) (built: Sep  9 2014 14:27:18) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies