# Homebrew No-Sudo Policy
## Rule
Homebrew commands MUST NEVER be run with sudo. Permission issues must be resolved by fixing directory ownership, not by elevating privileges.
## Why
Homebrew is designed to run in user space (/opt/homebrew on Apple Silicon, /usr/local on Intel Mac). Using sudo creates root-owned files that cause cascading permission errors.
## Examples
### Good
```bash
brew install git
brew upgrade
brew services start postgresql@16
```
### Bad
```bash
sudo brew install git # NEVER
sudo brew upgrade # NEVER
sudo brew services start ... # NEVER
```
## Fixing Permission Errors
```bash
# Fix Homebrew prefix ownership
sudo chown -R $(whoami) $(brew --prefix)/*
# Fix specific directories
sudo chown -R $(whoami) /opt/homebrew/var/log
sudo chown -R $(whoami) /opt/homebrew/var/run
# Fix Cellar permissions
sudo chown -R $(whoami) $(brew --cellar)
# Verify with brew doctor
brew doctor
```
## If sudo Was Already Used
```bash
# Reset all Homebrew permissions
sudo chown -R $(whoami) $(brew --prefix)
sudo chown -R $(whoami) $(brew --cellar)
sudo chown -R $(whoami) $(brew --caskroom)
sudo chown -R $(whoami) $(brew --prefix)/var/homebrew/linked
# Verify
brew doctor
```