Homebrew
Helpful commands while working with brew.
When trying to install using homebrew
User does not have permission to write to /usr/local/Cellar and throws following error.
Error: Cannot write to /usr/local/Cellar
Attempting to
sudo
Cowardly refusing to `sudo brew install'
You somehow have limited permissions to /usr/local/Cellar. Brew doesn’t like to install with sudo which is why it refuses. Correct the issue with the following commands:
-
Check the permissions:
ls -ld /usr/local/Cellar -
Open them up for writing:
sudo chmod a+w /usr/local/Cellar
Bundle
Bundle is a very useful command. This command will allow you to keep a backup of all installed packages from brew into a file. That can be backed up and reinstalled on different machines, or to clean up and reset your environments.
Creating Brewfile
To create the the Brewfile run the following command:
# To write to specific filebrew bundle dump --file=~/.eng/Brewfile# To write to current working directorybrew bundle dump
Installing from Brewfile
If you want to ensure you have all packages listed in your Brewfile installed, you can reinstall or do a fresh install (on a new machine) with the following command:
# Install from specific filebrew bundle --file=~/.eng/Brewfile# Install with Brewfile in current working directorybrew bundle
Resetting local environment
If your machine has gotten out of hand and you want to forcefully go back to only having packages listed in your Brewfile, you can run the following:
# Pointing to specific Brewfilebrew bundle --force cleanup --file=~/.eng/Brewfile# Pointing to Brewfile in current working directorybrew bundle --force cleanup
Housekeeping
-
: Removes all unused dependencies.autoremovebrew autoremove
-
: cleans up cached packages and old versions of installed packages. You can use thecleanupflag here to see what would be removed, before clearing is desired.--dry-run# This safely removes aged cache and packages.brew cleanup# This cleans up all regardless of age.brew cleanup --prune=all
Useful taps and packages
- homebrew-cask-fonts
- recommended font using IBM Plex, packaged by Nerd fonts to add glyphs for use in terminal settings.brew install font-blex-mono-nerd-font
- homebrew-graph