Brew Operations: Difference between revisions
Line 54: | Line 54: | ||
If no such cask is installed, the command issues an error message exits with 1. | If no such cask is installed, the command issues an error message exits with 1. | ||
==<tt>info</tt>== | ==<tt>info</tt>== | ||
Display statistics on the specific brew installation. If multiple version are present in the cellar, the active (linked) version is marked with *. | Display statistics on the specific brew installation. If multiple version are present in the cellar, the active (linked) version is marked with *. | ||
Line 63: | Line 62: | ||
brew info bash | brew info bash | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==<tt>install</tt>== | |||
==install== | |||
brew install <''formula-name''> | brew install <''formula-name''> | ||
===Install a Specific Package (Formula) Version=== | ===Install a Specific Package (Formula) Version=== | ||
{{External|https://blog.gruntwork.io/installing-multiple-versions-of-terraform-with-homebrew-899f6d124ff9}} | {{External|https://blog.gruntwork.io/installing-multiple-versions-of-terraform-with-homebrew-899f6d124ff9}} | ||
Line 86: | Line 82: | ||
Worked with terraform, [[Gradle_Installation#Install_a_Specific_Version|gradle]], [[Yq#Install_a_Specific_Version|yq]]. | Worked with terraform, [[Gradle_Installation#Install_a_Specific_Version|gradle]], [[Yq#Install_a_Specific_Version|yq]]. | ||
==update== | ==<tt>update</tt>== | ||
==<span id='uninstall'></span><tt>uninstall</tt> (<tt>remove</tt>, <tt>rm</tt>)== | ==<span id='uninstall'></span><tt>uninstall</tt> (<tt>remove</tt>, <tt>rm</tt>)== | ||
brew uninstall wget | brew uninstall wget | ||
==<tt>formula</tt>== | |||
==formula== | |||
Displays the path where the specified [[Brew_Concepts#Formula|formula]] is located. | Displays the path where the specified [[Brew_Concepts#Formula|formula]] is located. | ||
brew formula <''formula-name''> | brew formula <''formula-name''> | ||
==<tt>tap</tt>== | |||
==tap== | |||
Without any arguments, display all [[Brew_Concepts#Tap|taps]] available on the system: | Without any arguments, display all [[Brew_Concepts#Tap|taps]] available on the system: | ||
Line 115: | Line 108: | ||
For more about Homebrew Cask see: {{Internal|Brew_Concepts#Cask|Homebrew Cask}} | For more about Homebrew Cask see: {{Internal|Brew_Concepts#Cask|Homebrew Cask}} | ||
==pin/unpin== | ==<tt>pin</tt>/<tt>unpin</tt>== | ||
The <code>brew pin</code> command will prevent Homebrew from updating/upgrading the installed version of the specified formula when [[#upgrade|brew upgrade]] is executed. <code>brew unpin</code> releases this constraint. | The <code>brew pin</code> command will prevent Homebrew from updating/upgrading the installed version of the specified formula when [[#upgrade|brew upgrade]] is executed. <code>brew unpin</code> releases this constraint. | ||
==switch== | ==<tt>switch</tt>== | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
Usage: brew switch <formula> <version> | Usage: brew switch <formula> <version> | ||
Line 132: | Line 125: | ||
Alternative: [[#link|brew link]]. | Alternative: [[#link|brew link]]. | ||
==link== | ==<tt>link</tt>== | ||
The "link" command symlinks an installed package, located in /usr/local/Cellar to /usr/local. "link" works if the alternative versions are both installed in /usr/local/Cellar (for example /usr/local/Cellar/go and /usr/local/Cellar/go@1.12). "link" does not work if the alternative versions are installed as version subdirectories in the package Cellar directory. If there is a /usr/local/Cellar/yq/3.4.1 and a /usr/local/Cellar/yq/4.2.0, trying to use "brew link yq" does not work. In this situation, use [[#switch|brew switch]]. | The "link" command symlinks an installed package, located in /usr/local/Cellar to /usr/local. "link" works if the alternative versions are both installed in /usr/local/Cellar (for example /usr/local/Cellar/go and /usr/local/Cellar/go@1.12). "link" does not work if the alternative versions are installed as version subdirectories in the package Cellar directory. If there is a /usr/local/Cellar/yq/3.4.1 and a /usr/local/Cellar/yq/4.2.0, trying to use "brew link yq" does not work. In this situation, use [[#switch|brew switch]]. | ||
==unlink== | ==<tt>unlink</tt>== | ||
The 'unlink' command removes the symlink of installed package, located in /usr/local/Cellar to /usr/local | The 'unlink' command removes the symlink of installed package, located in /usr/local/Cellar to /usr/local | ||
Line 146: | Line 137: | ||
To the current version installed can be reported with [[#info|brew info <formula>]]. | To the current version installed can be reported with [[#info|brew info <formula>]]. | ||
==search== | ==<tt>search</tt>== | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> |
Revision as of 18:17, 5 July 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
Without any arguments, list all installed formulae or casks:
brew list
If --cask
is provided, list only installed casks, not formulae:
brew list --cask
When a specific formula or cask name is provided, list details about the installed artifacts associated with the formula or cask:
brew list bash
/usr/local/Cellar/bash/5.1.8/bin/bash
/usr/local/Cellar/bash/5.1.8/bin/bashbug
/usr/local/Cellar/bash/5.1.8/include/bash/ (58 files)
/usr/local/Cellar/bash/5.1.8/lib/bash/ (35 files)
/usr/local/Cellar/bash/5.1.8/lib/pkgconfig/bash.pc
/usr/local/Cellar/bash/5.1.8/share/doc/ (10 files)
/usr/local/Cellar/bash/5.1.8/share/info/bash.info
/usr/local/Cellar/bash/5.1.8/share/locale/ (39 files)
/usr/local/Cellar/bash/5.1.8/share/man/ (2 files)
brew list --cask corretto11
==> Pkg
amazon-corretto-11.0.11.9.1-macosx-x64.pkg (Pkg)
list versions
List versions for a specific formula or cask.
brew list --versions git-lfs
git-lfs 2.13.3
brew list --versions --cask corretto11
corretto11 11.0.11.9.1
If no such formula is installed, the command displays nothing and exits with 1.
If no such cask is installed, the command issues an error message 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
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 (remove, rm)
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-versions Tap
Why is this necessary? Why doesn't homebrew/cask suffice?
brew tap homebrew/cask-versions
For more about Homebrew Cask see:
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. "link" works if the alternative versions are both installed in /usr/local/Cellar (for example /usr/local/Cellar/go and /usr/local/Cellar/go@1.12). "link" does not work if the alternative versions are installed as version subdirectories in the package Cellar directory. If there is a /usr/local/Cellar/yq/3.4.1 and a /usr/local/Cellar/yq/4.2.0, trying to use "brew link yq" does not work. In this situation, use brew 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>.
search
brew search corretto11
Performs a substring (or regex) search of cask tokens and formula names. If the text is flanked by //, it is interpreted as a regular expression. The search is local and then on-line in homebrew/core and homebrew/cask.
cask
cask list
See list
above.
cask install
Install the Latest Version
Install the latest version of a cask:
brew install --cask 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 uninstall --cask vagrant
Recipes
Full Upgrade and Cleanup
brew update && brew outdated && brew upgrade && brew cleanup