Brew Operations: Difference between revisions
(Created page with "=Internal= * brew =Commands= ==update== Fetches the latest version of Homebrew and all formulae and upgrades. ==doctor== Chec...") |
|||
(113 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [[Brew#Subjects|brew]] | * [[Brew#Subjects|brew]] | ||
* [[Brew_Concepts#Overview|brew Concepts]] | |||
=Commands= | =Commands= | ||
==<tt>update</tt>== | |||
Fetches the latest version of Homebrew and all [[Brew_Concepts#Formula|formulae]] and upgrades. Use this to update brew itself. | |||
==<tt>upgrade</tt>== | |||
Upgrades software packages managed by brew to their latest versions. | |||
<syntaxhighlight lang='bash'> | |||
brew upgrade postgresql@14 | |||
</syntaxhighlight> | |||
== | ==<tt>doctor</tt>== | ||
Checks the Homebrew installation for potential problems and exit with a non-zero status if potential problems are found. | |||
==<tt>cleanup</tt>== | |||
Remove old version from [[Brew_Concepts#Cellar|cellar]] for all installed (or specified) [[Brew_Concepts#Formula|formulae]]. Old downloads from the Homebrew download-cache are deleted. | |||
==<tt>list</tt>== | |||
Without any arguments, list all installed [[Brew_Concepts#Formula|formulae]] or [[Brew_Concepts#Cask|casks]]: | |||
<syntaxhighlight lang='bash'> | |||
brew list | |||
</syntaxhighlight> | |||
If <code>--cask</code> is provided, list only installed casks, not formulae: | |||
<syntaxhighlight lang='bash'> | |||
brew list --cask | |||
</syntaxhighlight> | |||
When a specific formula or cask name is provided, list details about the installed artifacts associated with the formula or cask: | |||
<syntaxhighlight lang='bash'> | |||
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) | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
brew list --cask corretto11 | |||
==> Pkg | |||
amazon-corretto-11.0.11.9.1-macosx-x64.pkg (Pkg) | |||
</syntaxhighlight> | |||
===list versions=== | |||
List versions for a specific formula or cask. | |||
<syntaxhighlight lang='bash'> | |||
brew list --versions git-lfs | |||
git-lfs 2.13.3 | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
brew list --versions --cask corretto11 | |||
corretto11 11.0.11.9.1 | |||
</syntaxhighlight> | |||
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. | |||
==<tt>info</tt>== | |||
Display statistics on the specific formula or [[Brew_Concepts#Cask|cask]]. Note that the formula or cask does not have to be currently installed on the system to get information. If the cask is not installed, the command will still provide names, descriptions and artifacts, but it will mention "Not installed". | |||
If multiple version are present in the cellar, the active (linked) version is marked with *. By default assumes the names that are provided are formulae: | |||
<syntaxhighlight lang='bash'> | |||
brew info bash | |||
</syntaxhighlight> | |||
To display information about casks, use <code>--cask</code>: | |||
<syntaxhighlight lang='bash'> | |||
brew info --cask corretto11 | |||
</syntaxhighlight> | |||
==<span id='Install_the_Latest_Version'></span><tt>install</tt>== | |||
Install the latest version of a formula or a cask: | |||
<syntaxhighlight lang='bash'> | |||
brew install <formula-name> | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
brew install --cask <cask-name> | |||
</syntaxhighlight> | |||
Homebrew formulae or casks can be installed with Ansible, which provides modules that delegate to Homebrew native commands. For more details see: {{Internal|Ansible_Modules_homebrew_and_homebrew_cask#Overview|Ansible Homebrew Support}} | |||
===<span id='Install_a_Specific_Package_.28Formula.29_Version'></span>Install a Specific Formula Version=== | |||
{{External|https://blog.gruntwork.io/installing-multiple-versions-of-terraform-with-homebrew-899f6d124ff9}} | |||
{{External|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_Installation#Install_a_Specific_Version|gradle]], [[Yq#Install_a_Specific_Version|yq]]. | |||
===<span id='Install_a_Specific_Version'></span>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 <code>vagrant.rb</code>): | |||
git log master -- Casks/vagrant.rb | |||
Based on the commit comment, pick the commit corresponding to the desired version: | |||
<syntaxhighlight lang='text'> | |||
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) | |||
</syntaxhighlight> | |||
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 | |||
==<span id='uninstall'></span><tt>uninstall</tt> (<tt>remove</tt>, <tt>rm</tt>)== | |||
Uninstall a formula or a cask. By default it assumes formulae. | |||
<syntaxhighlight lang='bash'> | |||
brew uninstall wget | |||
</syntaxhighlight> | |||
<span id='cask_uninstall'></span>Specify <code>--cask</code> to configure it to uninstall one or more casks: | |||
<syntaxhighlight lang='bash'> | |||
brew uninstall --cask corretto11 | |||
</syntaxhighlight> | |||
After the execution of a cask uninstall command, the whole directory associated with the cask is removed from [[Brew_Concepts#Caskroom|Caskroom]]. | |||
==<tt>formula</tt>== | |||
Displays the path where the specified [[Brew_Concepts#Formula|formula]] is located. | |||
brew formula <''formula-name''> | |||
==<tt>tap</tt>== | |||
Without any arguments, display all [[Brew_Concepts#Tap|taps]] available on the system: | |||
brew tap | |||
===Add a New Tap=== | |||
brew tap [--full] <''user''>/<''repo''> [''URL''] | |||
===<span id='Install_Homebrew_Cask'></span>Install homebrew/cask-versions Tap=== | |||
<font color=darkgray>Why is this necessary? Why doesn't homebrew/cask suffice?</font> | |||
<syntaxhighlight lang='bash'> | |||
brew tap homebrew/cask-versions | |||
</syntaxhighlight> | |||
For more about Homebrew Cask see: {{Internal|Brew_Concepts#Cask|Homebrew Cask}} | |||
==<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. | |||
==<tt>switch</tt>== | |||
<syntaxhighlight lang='bash'> | |||
Usage: brew switch <formula> <version> | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
brew switch mysql 5.5.29 | |||
</syntaxhighlight> | |||
<font color=darkgray>Does it need to exist in Cellar?</font> | |||
Alternative: [[#link|brew 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]]. | |||
==<tt>unlink</tt>== | |||
The 'unlink' command removes the symlink of installed package, located in /usr/local/Cellar to /usr/local | |||
<syntaxhighlight lang='bash'> | |||
brew unlink git | |||
</syntaxhighlight> | |||
To the current version installed can be reported with [[#info|brew info <formula>]]. | |||
==<tt>search</tt>== | |||
= | <syntaxhighlight lang='bash'> | ||
brew search corretto11 | |||
</syntaxhighlight> | |||
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. | |||
==<tt>bundle</tt>== | |||
Install <code>brew bundle</code> and write installed casks/formulae/images/taps into <code>~/Brewfile</code>: | |||
<syntaxhighlight lang='bash'> | |||
brew bundle dump --file=~/Brewfile | |||
</syntaxhighlight> | |||
This can be used to save information about all packages installed on the system. They can be reinstalled with: | |||
<syntaxhighlight lang='bash'> | |||
brew bundle install --file=~/Brewfile | |||
</syntaxhighlight> | |||
==<tt>services</tt>== | |||
<syntaxhighlight lang='bash'> | |||
brew services start <service-name> | |||
brew services stop <service-name> | |||
</syntaxhighlight> | |||
Examples: | |||
* [[PostgreSQL_Installation_on_Mac#Operate_the_Database_as_a_Service|Starting PostgreSQL]] | |||
* [[Httpd_on_Mac#Start_at_Boot|Starting httpd]] | |||
* [[MariaDB_Installation#To_Start_at_Boot|Starting MariaDB]] | |||
===<tt>services list</tt>=== | |||
= | =cask= | ||
==cask list== | |||
See <code>[[#list|list]]</code> command above. | |||
==cask install== | |||
See <code>[[#install|install]]</code> command above. | |||
==cask uninstall== | |||
See <code>[[#cask_uninstall|uninstall]]</code> command above. | |||
=Recipes= | |||
==Full Upgrade and Cleanup== | |||
<syntaxhighlight lang='bash'> | |||
brew update && brew outdated && brew upgrade && brew cleanup | |||
</syntaxhighlight> |
Latest revision as of 19:43, 18 April 2024
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.
brew upgrade postgresql@14
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 formula or cask. Note that the formula or cask does not have to be currently installed on the system to get information. If the cask is not installed, the command will still provide names, descriptions and artifacts, but it will mention "Not installed".
If multiple version are present in the cellar, the active (linked) version is marked with *. By default assumes the names that are provided are formulae:
brew info bash
To display information about casks, use --cask
:
brew info --cask corretto11
install
Install the latest version of a formula or a cask:
brew install <formula-name>
brew install --cask <cask-name>
Homebrew formulae or casks can be installed with Ansible, which provides modules that delegate to Homebrew native commands. For more details see:
Install a Specific 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.
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
uninstall (remove, rm)
Uninstall a formula or a cask. By default it assumes formulae.
brew uninstall wget
Specify --cask
to configure it to uninstall one or more casks:
brew uninstall --cask corretto11
After the execution of a cask uninstall command, the whole directory associated with the cask is removed from Caskroom.
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.
bundle
Install brew bundle
and write installed casks/formulae/images/taps into ~/Brewfile
:
brew bundle dump --file=~/Brewfile
This can be used to save information about all packages installed on the system. They can be reinstalled with:
brew bundle install --file=~/Brewfile
services
brew services start <service-name>
brew services stop <service-name>
Examples:
services list
cask
cask list
See list
command above.
cask install
See install
command above.
cask uninstall
See uninstall
command above.
Recipes
Full Upgrade and Cleanup
brew update && brew outdated && brew upgrade && brew cleanup