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/CellarAttempting to sudo it refuses with following error.
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 file
brew bundle dump --file=~/.eng/Brewfile
# To write to current working directory
brew bundle dumpInstalling 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 file
brew bundle --file=~/.eng/Brewfile
# Install with Brewfile in current working directory
brew bundleNote:
TIP: if you want to overwrite an existing brew file add the --force flag to the above command.
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 Brewfile
brew bundle --force cleanup --file=~/.eng/Brewfile
# Pointing to Brewfile in current working directory
brew bundle --force cleanupHousekeeping
-
autoremove: Removes all unused dependencies.brew autoremove -
cleanup: cleans up cached packages and old versions of installed packages. You can use the--dry-runflag here to see what would be removed, before clearing is desired.# 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
brew install font-blex-mono-nerd-fontrecommended font using IBM Plex, packaged by Nerd fonts to add glyphs for use in terminal settings.
- homebrew-graph