# Brewfile example
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
brew "git"
brew "node"
brew "python"
brew "docker"
cask "visual-studio-code"
cask "google-chrome"
cask "slack"
mas "Xcode", id: 497799835
Command
Description
brew bundle
Install from Brewfile
brew bundle dump
Create Brewfile
brew bundle cleanup
Uninstall unlisted packages
brew bundle check
Check Brewfile status
Configuration
Environment Variables
Variable
Description
HOMEBREW_PREFIX
Installation prefix
HOMEBREW_CELLAR
Package installation directory
HOMEBREW_REPOSITORY
Homebrew repository location
HOMEBREW_CACHE
Download cache directory
Configuration Files
File
Description
~/.homebrew/
User configuration
/opt/homebrew/
Installation directory (Apple Silicon)
/usr/local/
Installation directory (Intel)
Brewfile
Package bundle file
Troubleshooting
Common Issues
Problem
Solution
Permission errors
sudo chown -R $(whoami) /opt/homebrew
Outdated Xcode tools
xcode-select --install
Broken symlinks
brew doctor && brew cleanup
Formula conflicts
brew unlink package && brew link package
Reset and Reinstall
Command
Description
brew uninstall --force package_name
Force uninstall
brew reinstall package_name
Reinstall package
brew link --overwrite package_name
Force link
brew prune
Remove dead symlinks
Debugging
Command
Description
brew --debug install package
Debug installation
brew --verbose install package
Verbose installation
brew gist-logs package_name
Create gist of logs
Performance Optimization
Parallel Operations
# Enable parallel downloads
export HOMEBREW_PARALLEL=4
# Disable analytics
export HOMEBREW_NO_ANALYTICS=1
# Use faster GitHub API
export HOMEBREW_GITHUB_API_TOKEN=your_token
Cache Management
Command
Description
brew cleanup --prune=7
Keep 7 days of downloads
du -sh $(brew --cache)
Check cache size
rm -rf $(brew --cache)
Clear all cache
Security
Package Verification
Command
Description
brew audit package_name
Audit package formula
brew style package_name
Check formula style
brew install --verbose package
Show detailed install process
Safe Practices
Regular Updates: Keep Homebrew and packages updated
Trusted Taps: Only add trusted third-party taps
Review Formulas: Check formulas before installation
Backup: Maintain Brewfile for easy restoration
Permissions: Avoid running with sudo
Integration
Shell Integration
# Bash completion
if type brew &>/dev/null; then
HOMEBREW_PREFIX="$(brew --prefix)"
if [[ -r "$\\\\{HOMEBREW_PREFIX\\\\}/etc/profile.d/bash_completion.sh" ]]; then
source "$\\\\{HOMEBREW_PREFIX\\\\}/etc/profile.d/bash_completion.sh"
fi
fi
# Zsh completion
if type brew &>/dev/null; then
FPATH="$(brew --prefix)/share/zsh/site-functions:$\\\\{FPATH\\\\}"
autoload -Uz compinit
compinit
fi