Homebrew Cheatsheet ¶
Homebrew cheatsheet (outdated: some commands - notably switch - have been removed)
Commands
brew install git | Install a package |
brew uninstall git | Remove/Uninstall a package |
brew upgrade git | Upgrade a package |
brew unlink git | Unlink |
brew link git | Link |
brew switch git 2.5.0 | Change versions |
brew list --versions git | See what versions you have |
More package commands
brew info git | List versions, caveats, etc |
brew cleanup git | Remove old versions |
brew edit git | Edit this formula |
brew cat git | Print this formula |
brew home git | Open homepage |
brew search git | Search for formulas |
Global commands
brew update | Update brew and cask |
brew list | List installed |
brew outdated | What’s due for upgrades? |
brew doctor | Diagnose brew issues |
Brew Cask commands
brew cask install firefox | Install the Firefox browser |
brew cask list | List installed applications |
(*) Cask commands are used for interacting with graphical applications.
Credits:
https://devhints.io/homebrew
See also:
Uninstalling homebrew
From https://osxdaily.com/2018/08/12/how-uninstall-homebrew-mac/:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
From https://apple.stackexchange.com/questions/82807/how-to-cleanly-remove-homebrew#82808:
cd /tmp cd `brew --prefix` rm -rf Cellar brew prune rm `git ls-files` rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions rm -rf .git rm -rf ~/Library/Caches/Homebrew
Homebrew Multi User Setup
From https://medium.com/@leifhanack/homebrew-multi-user-setup-e10cb5849d59:
- Create a group brew and add Stan
- brew doctor (Allen checks if he installed brew correctly)
- sudo chgrp -R brew $(brew --prefix)/* (Change the group of homebrew installation directory)
- sudo chmod -R g+w $(brew --prefix)/* (Allow group members to write inside this directory)
- brew doctor (Stan checks if he can use homebrew)
- We are done!
Example: How to install a specific version of python3 on OS X
Since switch has been removed from brew, we proceed as follows ...
Install the desided version:
brew install python@3.8
List available versions:
brew list | grep python python@3.8 python@3.9
Change versions:
brew unlink python@3.8 brew unlink python@3.9 brew link --overwrite python@3.8
Check:
python3 --version Python 3.8.7
Then you might also want to reinstall virtualenvwrapper for the new active Python interpreter:
pip3 install virtualenvwrapper
If this doesn't work due to "error: externally-managed-environment", try the following:
pip install virtualenvwrapper --break-system-packages
List existing versions of a formula (example)
brew search '/^redis$|^redis@/' ==> Formulae redis ✔ redis@3.2 redis@4.0 redis@6.2
or, lookup into detailed info:
brew info --json redis
How to upgrade PostgreSQL with Homebrew
https://www.moncefbelyamani.com/how-to-upgrade-postgresql-with-homebrew/
A Beginner’s Guide to Homebrew
https://medium.com/@kkworden/a-beginners-guide-to-homebrew-4b665956a74
List dependencies
$ brew deps teleport brotli c-ares ca-certificates icu4c libcbor libfido2 libnghttp2 libuv node openssl@3
or:
$ brew deps teleport --tree teleport ├── libfido2 │ ├── libcbor │ └── openssl@3 │ └── ca-certificates ├── node │ ├── brotli │ ├── c-ares │ ├── icu4c │ ├── libnghttp2 │ ├── libuv │ └── openssl@3 │ └── ca-certificates └── openssl@3 └── ca-certificates
Credits: