# Homebrew
|  | Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, macOS, as well as Linux. The name is intended to suggest the idea of building software on the Mac depending on the user's taste. Originally written by Max Howell, the package manager has gained popularity in the Ruby on Rails community and earned praise for its extensibility. Homebrew has been recommended for its ease of use as well as its integration into the command-line interface. Homebrew is a member of the Open Source Collective, and is run entirely by unpaid volunteers. |
|-|-|
| | wikipedia:: [Homebrew (package manager)](https://en.wikipedia.org/wiki/Homebrew_(package_manager)) |
[[Apple]]
- https://brew.sh
Brew only knows about apps you install with brew, not apps you manually download. So, in general, install apps with brew.
You can always do a brew dump to see what the machine has currently installed. E.g., to migrate or to update the dev-env brewfile.
## TERMINOLOGY
**formula**: Homebrew package definition built from upstream sources (usually from taps), the core thing that homebrew does - installs unix-like packages
**cask**: Homebrew package definition that installs macOS native applications (binaries)
**keg**: installation destination directory of a given **formula** version e.g. `/usr/local/Cellar/foo/0.1`
**rack**: directory containing one or more versioned kegs e.g. `/usr/local/Cellar/foo`
**keg-only**: a **formula** is **keg-only** if it is not symlinked into Homebrew’s prefix (e.g. `/usr/local`)
**cellar**: directory containing one or more named **racks** e.g. `/usr/local/Cellar`
**Caskroom**: directory containing one or more named **casks** e.g. `/usr/local/Caskroom`
**external command**: `brew` subcommand defined outside of the Homebrew/brew GitHub repository
**tap**: directory (and usually Git repository) of **formulae**, **casks** and/or **external commands**
**bottle**: pre-built **keg** poured into the **cellar**/**rack** instead of building from upstream sources
### Taps, Formulas, Casks
- Homebrew-Cask is an extension to Homebrew to install GUI applications such as Google Chrome or Atom. It started independently but its maintainers now work closely with Homebrew’s core team. Homebrew calls its package definition files “formulae” (British plural for “formula”). Homebrew-Cask calls them “casks”. A cask, just like a formula, is a file written in a Ruby-based DSL that describes how to install something. The Cellar is where Homebrew installs things. Its default path is /usr/local/Cellar. It then add symlinks from standard locations to it. For example, when you type brew install git: 1 Homebrew installs it under /usr/local/Cellar/git//, with the git binary in /usr/local/Cellar/git//bin/git 2 It adds a symlink from /usr/local/bin/git to that binary This allows Homebrew to keep track of what’s installed by Homebrew versus software installed by other means. A tap is a source of formulae. The default is homebrew/core but you can add more of them. The simplest way to create a formula for your own software is to create a GitHub repository called homebrew-; put your formula file in it; then type brew tap / to add this new source of formulae to your Homebrew installation and so get access to all its formulae. Some companies have internal Homebrew taps for their own utilities. There are a lot of public taps like homebrew/science for scientific software, atlassian/tap for Atlassian software, and ska-sa/tap for radio astronomy.
- brew install something is for CLI packages, brew cask install something is for GUI apps
## Usage
### Commands
`brew`
- `list`
- lists installed formulas
- `cask`
- `list`
- lists installed casks (macOS binaries)
- install
- installs formula
- uninstall
- uninstalls formula
- update
- Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations. (Doesn't update installed software, just updates what brew knows about - latest versions etc.)
- upgrade
- Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally installed with, plus any appended brew formula options. If _`cask`_ or _`formula`_ are specified, upgrade only the given _`cask`_ or _`formula`_ kegs (unless they are pinned; see `pin`, `unpin`). I.e., upgrades the installed software you have on your system to the latest versions.
- --greedy
- As a general rule don't use this since it exacerbates the potential of losing user settings from casks.
- https://apple.stackexchange.com/questions/465032/brew-how-to-stop-losing-app-settings-when-updating
- search
- searches formulas and casks of known taps
- info
- bundle
- install everything listed in the Brewfile
- dump
- generate a file called `Brewfile` listing **all** of the installed brew packages, cask applications, and Mac App Store applications currently on the machine.
- --describe
- dump adds a description comment above each line, unless the dependency does not have a description.
- cleanup
- check
- Check if all dependencies are installed from the Brewfile.
- list
- List all dependencies present in the Brewfile. (only brew? not cask?)
- --cask
- --mas
- --whalebrew
- --describe
- adds description to each package
- --debug
- -t
- ordered by install date
- -1 one line per entry
- cleanup
- remove various brew files no longer needed
- brew installs versions side by side and keeps older versions. Cleanup removes the older versions and any packages not listed in your Brewfile
- autoremove
- Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.
- `-n`, `--dry-run`: List what would be uninstalled, but do not actually uninstall anything.
- doctor
- desc
- home
- Where does stuff get downloaded?
- brew --cache
- commands
- lists brew commands
- docs
- fetch
- home
- Open a _`formula`_ or _`cask`_’s homepage in a browser, or open Homebrew’s own homepage if no argument is provided.
### Mas
mas
- search
- also returns id of the app
- info {id}
- list
### Services
- Update
- brew services update someService
- Upgrade
- brew services upgrade someService
- Start
- Start the service formula immediately and register it to launch at login (or boot).
- brew services start someService
- Stop
- Stop the service formula immediately and unregister it from launching at login (or boot).
- brew services stop someService
- Restart
- brew services restart someService
- kill
- Stop the service formula immediately but keep it registered to launch at login (or boot).
- run
- Run the service formula without registering to launch at login (or boot).
- info
- list
## Versions
## Mas app store apps
## Whalebrew for Docker images
## Brew Bundle
### Brew file extension to Brew bundle?
- [Usage — Homebrew-file 8.5.6 documentation](https://homebrew-file.readthedocs.io/en/latest/usage.html)
- [ ] [actions](https://apps.apple.com/us/app/actions/id1586435171?uo=4&at=10l4tL&ct=searchlink)
## Packages
```dataview
TABLE WITHOUT ID
file.link AS Name, brew
FROM #Type
WHERE brew != null
```
## Sources
- [My Brewfile - DEV Community](https://dev.to/mattstratton/my-brewfile-1pob)
- [mattstratton/matty-dotfiles: My dotfiles and stuff](https://github.com/mattstratton/matty-dotfiles/tree/master)
> [!note]- Note: *The --greedy option might cause data loss if app stores data in the app folder*
> Homebrew Cask by default won't automatically update apps with **built-in update** function / utility / etc. Since Homebrew Cask upgrade apps by **removing** and **reinstalling** `.app` (excl. data in `~/Library/Application Support`, etc), you may lose data for some apps like MultiMC.app which stores data inside its `.app` folder. I lost all my game saves for once. Although it's rare, there's certainly possibility of encountering such problem.
> - [Homebrew casks are not updating, how can I fix this? - Ask Different](https://apple.stackexchange.com/questions/432198/homebrew-casks-are-not-updating-how-can-i-fix-this)