Homebrew: Error: Permission denied @ dir_s_mkdir - /usr/local/Cellar / /opt/homebrew is not writable
Homebrew can't write to its prefix because the folders are owned by another user or root.
Error: Permission denied @ dir_s_mkdir - /usr/local/CellarError: /opt/homebrew is not writablePermission denied @ dir_s_mkdirError: Permission denied @ rb_sysopen - /usr/local/Error: The following directories are not writable by your user Meaning
Homebrew should be owned by your user. Fix ownership with sudo chown -R $(whoami) $(brew --prefix)/* (Intel: /usr/local; Apple Silicon: /opt/homebrew), and make sure you never run sudo brew. brew doctor lists the exact problems.
Common causes
- Installed with sudo or by another user
- Ownership changed by migration/restore
- Mixed Intel/ARM Homebrew prefixes
- Running brew as root
- Folder missing (/usr/local/share/man)
⚡ Quick fix
sudo chown -R $(whoami) $(brew --prefix)/*brew doctorand fix what it reports- Never use
sudo brew
Detailed fix by platform
macOS
brew --prefix && ls -ld $(brew --prefix) && brew doctor
How to diagnose
- Prefix — /opt/homebrew or /usr/local?
- Owner — You?
- Sudo — Used before?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- avc: denied SELinux is preventing ... / avc: denied { read } for pid=... (permission denied despite correct permissions)
- daemon Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- Docker Desktop requires privileged access (vmnetd) macOS: Docker Desktop needs privileged access / com.docker.vmnetd could not be started
Most viewed in macOS
- is damaged and can’t be opened macOS: “App” is damaged and can’t be opened. You should move it to the Trash.
- git: 'credential-osxkeychain' is not a git command Git: git: 'credential-osxkeychain' is not a git command. See 'git --help'
- fork: Resource temporarily unavailable macOS: -bash: fork: Resource temporarily unavailable (process limit reached)
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026