Brew Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 130: Line 130:


The 'link' command symlinks an installed package, located in /usr/local/Cellar to /usr/local. Useful if the Cellar contains more than one versions:
The 'link' command symlinks an installed package, located in /usr/local/Cellar to /usr/local. Useful if the Cellar contains more than one versions:
<font color=darkgray>TODO, untested.</font>
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
brew link yq
brew link yq @4.2.0
</syntaxhighlight>
</syntaxhighlight>



Revision as of 02:36, 7 January 2021

Internal

Commands

update

Fetches the latest version of Homebrew and all formulae and upgrades. Use this to update brew itself.

upgrade

Upgrades software packages managed by brew to their latest versions.

doctor

Checks the Homebrew installation for potential problems and exit with a non-zero status if potential problems are found.

cleanup

Remove old version from cellar for all installed (or specified) formulae. Old downloads from the Homebrew download-cache are deleted.

list

Lists all installed formulae.

With a specific argument, list details about the installed artifacts associated with a specific formula.

brew list
brew list <formula>

Example:

brew list bash
/usr/local/Cellar/bash/4.4.19/bin/bash
/usr/local/Cellar/bash/4.4.19/bin/bashbug
/usr/local/Cellar/bash/4.4.19/include/bash/ (58 files)
/usr/local/Cellar/bash/4.4.19/lib/bash/ (26 files)
/usr/local/Cellar/bash/4.4.19/lib/pkgconfig/bash.pc
/usr/local/Cellar/bash/4.4.19/share/doc/ (10 files)
/usr/local/Cellar/bash/4.4.19/share/info/bash.info
/usr/local/Cellar/bash/4.4.19/share/locale/ (37 files)
/usr/local/Cellar/bash/4.4.19/share/man/ (2 files)

list versions

brew list --versions git-lfs

If no such formula is installed, the command exits with 1.

info

Display statistics on the specific brew installation. If multiple version are present in the cellar, the active (linked) version is marked with *.

brew info <formula>
brew info bash

install

brew install <formula-name>

Install a Specific Package (Formula) Version

https://blog.gruntwork.io/installing-multiple-versions-of-terraform-with-homebrew-899f6d124ff9
https://medium.com/@warrensbox/how-to-manage-different-terraform-versions-for-each-project-51cca80ccece

To install a specific formula version, follow this procedure, exemplified with terraform (if you need to apply it to a different formula, you might need to adapt it).

git clone git@github.com:Homebrew/homebrew-core.git
cd homebrew-core
git log master -- Formula/terraform.rb
# find the specific version and write down the commit
git checkout <commit>
cp Formula/terraform.rb ~/tmp
cd ~/tmp
brew unlink terraform
brew install ./terraform.rb

Worked with terraform, gradle, yq.

update

uninstall

brew uninstall wget

formula

Displays the path where the specified formula is located.

brew formula <formula-name>

tap

Without any arguments, display all taps available on the system:

brew tap

Add a New Tap

brew tap [--full] <user>/<repo> [URL]

Install Homebrew Cask

brew tap caskroom/cask

For more about Homebrew Cask see:

Homebrew Cask

pin/unpin

The brew pin command will prevent Homebrew from updating/upgrading the installed version of the specified formula when brew upgrade is executed. brew unpin releases this constraint.

switch

Usage: brew switch <formula> <version>
brew switch mysql 5.5.29

Does it need to exist in Cellar?

Alternative: brew link.

link

The 'link' command symlinks an installed package, located in /usr/local/Cellar to /usr/local. Useful if the Cellar contains more than one versions:

brew link yq @4.2.0

Also see switch.

unlink

The 'unlink' command removes the symlink of installed package, located in /usr/local/Cellar to /usr/local

brew unlink git

To the current version installed can be reported with brew info <formula>.

cask

cask list

brew cask list

With no args, lists installed casks.

brew cask audit

cask install

Install the Latest Version

Install the latest version of a cask:

brew cask install vagrant

Install a Specific Cask Version

It seems it's a big deal to revert to a specific version with Vagrant, it requires low level intervention: https://www.jverdeyen.be/mac/downgrade-brew-cask-application/.

This is a step-by-step example for Vagrant.

Clone the Homebrew homebrew-cask repository:

git clone git@github.com:Homebrew/homebrew-cask.git

Pull the history of the specific cask you want to downgrade (in this case vagrant.rb):

git log master -- Casks/vagrant.rb

Based on the commit comment, pick the commit corresponding to the desired version:

commit ae2a540ffee555491ccbb2cefa4296c76355ef9f
Author: Nikolas Evers <vintagesucks@users.noreply.github.com>
Date:   Tue Oct 15 12:22:12 2019 +0200

    Update vagrant from 2.2.5 to 2.2.6 (#70854)

Uninstall the current version:

brew cask uninstall vagrant

Using the commit identified above, install the desired version:

brew cask install https://raw.githubusercontent.com/caskroom/homebrew-cask/ae2a540ffee555491ccbb2cefa4296c76355ef9f/Casks/vagrant.rb

cask uninstall

Uninstall the specified cask:

brew cask uninstall vagrant