BugMedic

Homebrew “Permission denied” on install: fix prefix ownership

Run brew doctor, then restore your user's ownership of exactly the directories it flags.

By BugMedic editorial teamLast source review: 2026-10-03macOS

Never sudo brew. Run brew doctor and fix exactly what it reports: restore your ownership of the flagged prefix directories (for example, sudo chown -R $(whoami) $(brew --prefix)/Cellar), then retry the install.

Try these fixes in order

01

Run brew doctor

brew doctor diagnoses prefix ownership and permission problems specifically; follow its output, not a forum post.

brew doctor
02

Confirm your prefix

Confirm which prefix your brew uses so the fix targets the right directories.

brew --prefix
03

Restore ownership of flagged directories

Apply this only to the directories brew doctor flagged. Adjust the path to your prefix if it differs.

sudo chown -R $(whoami) $(brew --prefix)/Cellar
04

Retry the install

The install should now create directories without permission errors.

brew install wget

Interpret what you see

Installs fail but brew update works

What it suggests: Homebrew expects the installing user to own the prefix; brew doctor names the specific directories that are wrong.

Next check: Run brew doctor and read every warning before changing anything.

You found a blanket chown command in an old forum post

What it suggests: The official troubleshooting guidance warns against applying ownership changes from old issue reports without understanding which files they affect.

Next check: Apply ownership fixes only to the directories brew doctor names, not the whole disk.

You are unsure which prefix is in play

What it suggests: On Apple Silicon the prefix is /opt/homebrew; on Intel it is /usr/local. The fix targets whichever prefix your brew uses.

Next check: Check brew --prefix to target the right one.

Why this happens

  • The Homebrew prefix directories are not writable by your user (ownership changed after migration or restore).
  • A system cleaner or another tool reset permissions under the prefix.

Still not working?

Do not run brew with sudo to work around this; Homebrew explicitly refuses sudo for installs and it would create root-owned files that break future runs worse. Fix the ownership instead.

Official sources

These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.

Related Homebrew guides