How to Fix Homebrew Permission Denied on usr local or opt homebrew on Mac mini M1: Senior Engineer macOS Guide
⚡ Quick 60-Second Verdict: What This Issue Means
Your Mac mini M1’s Homebrew installation at /opt/homebrew (Apple Silicon default) or /usr/local (legacy Intel path) has incorrect POSIX ownership or ACLs—usually caused by running sudo brew, manual chown/chmod, or a migration from an Intel Mac. The fix is restoring recursive ownership to your admin user and clearing any restrictive ACLs; no reinstall or SIP disable required.
- NEVER run
sudo brew install,sudo brew update, orsudo brew upgrade. Homebrew is designed to run as your regular admin user; sudo corrupts ownership and breaks future non-sudo runs. - DO NOT
chmod -R 777orchown -R root:wheelon/opt/homebrew. World-writable directories are a severe security risk; root ownership breaks Homebrew’s sandbox model and prevents formula installs. - DO NOT disable System Integrity Protection (SIP) to “fix” permissions. SIP protects
/usron macOS; Homebrew on Apple Silicon uses/opt/homebrewprecisely to avoid SIP conflicts. - AVOID blindly copying fixes from Stack Overflow that target
/usr/local. On M1/M2/M3 Mac mini, Homebrew lives at/opt/homebrew. Applying/usr/localcommands to the wrong path wastes time and masks the real issue.
1. Immediate Safe Actions (Non-Destructive User Triage)
Three straightforward, non-destructive initial triage steps tailored specifically to Homebrew Permission Denied on /opt/homebrew or /usr/local on Mac mini M1:
Identify the Correct Homebrew Prefix & Current Ownership
On Apple Silicon Mac mini M1, Homebrew installs to /opt/homebrew by default. Verify which prefix exists and who owns it. Open Terminal (⌘+Space → Terminal) and run:
# Check both possible prefixes
ls -ld /opt/homebrew /usr/local 2>/dev/null | awk '{print $1, $3, $4, $NF}'
# If /opt/homebrew exists (standard on M1), inspect recursively
ls -la /opt/homebrew | head -20
Expected healthy output: Directory owned by your_admin_username:admin (e.g., jdoe:admin) with drwxr-xr-x permissions. If you see root:wheel, root:admin, or any + suffix (ACL present), proceed to Step 02.
Restore Recursive Ownership & Strip ACLs (The Canonical Fix)
Run the following commands exactly as shown—no sudo inside the chown argument. Replace $(whoami) with your short username if preferred. This fixes /opt/homebrew (primary) and /usr/local (fallback) safely.
# 1. Fix ownership recursively (your user, group admin)
sudo chown -R "$(whoami):admin" /opt/homebrew 2>/dev/null
sudo chown -R "$(whoami):admin" /usr/local 2>/dev/null
# 2. Remove any lingering ACL entries (the '+' in ls -le)
sudo chmod -R -N /opt/homebrew 2>/dev/null
sudo chmod -R -N /usr/local 2>/dev/null
# 3. Ensure directories are traversable (755) and files readable (644)
find /opt/homebrew -type d -exec chmod 755 {} + 2>/dev/null
find /opt/homebrew -type f -exec chmod 644 {} + 2>/dev/null
find /usr/local -type d -exec chmod 755 {} + 2>/dev/null
find /usr/local -type f -exec chmod 644 {} + 2>/dev/null
# 4. Verify
ls -ld /opt/homebrew /usr/local
Why this works: chown -R user:admin restores the POSIX ownership Homebrew expects. chmod -R -N strips all Access Control Lists (ACLs) that silently block write access even when POSIX permissions look correct. The find calls normalize directory/file modes without over-permissioning.
Run brew doctor & brew update to Confirm Health
Now validate that Homebrew’s internal checks pass and the package database syncs.
# 1. Full diagnostic
brew doctor
# 2. Update formulae & Homebrew itself
brew update
# 3. Optional: verify no broken symlinks or missing kegs
brew missing 2>/dev/null || echo "All kegs linked correctly."
Success criteria: brew doctor returns “Your system is ready to brew.” or only non-critical warnings (e.g., “Unbrewed header files were found in /usr/local/include”). brew update completes without “Permission denied” errors. If you still see errors, proceed to Section 3 for deeper ACL/flag inspection.

2. Software False Alarm Recovery & Reset Protocol
Shell Environment & PATH Reset Sequence
If brew command not found or points to wrong prefix after ownership fix, your shell config may have stale PATH or eval lines. Perform this non-destructive reset:
- Identify your shell:
echo $SHELL(zsh default on Sonoma/Sequoia, bash on older). - Backup & edit config:
cp ~/.zprofile ~/.zprofile.bak.$(date +%s) 2>/dev/null cp ~/.zshrc ~/.zshrc.bak.$(date +%s) 2>/dev/null # Or for bash: cp ~/.bash_profile ~/.bash_profile.bak.$(date +%s) 2>/dev/null - Ensure only the Apple Silicon eval block exists (once):
# Append if missing; do NOT duplicate grep -q 'opt/homebrew/bin/brew shellenv' ~/.zprofile || echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile - Reload shell:
exec $SHELL -l(or close/reopen Terminal). - Verify:
which brew→/opt/homebrew/bin/brewandbrew --prefix→/opt/homebrew.
This clears volatile shell state and ensures the correct Homebrew environment loads on every new session.
3. Advanced Diagnostics & Component Triage
Deep ACL, Immutable Flag & SIP Status Verification
If Step 02–04 did not resolve “Permission denied”, inspect for macOS-specific extended attributes that survive chown/chmod.
# 1. List ACLs on the prefix root (should be empty after Step 02)
ls -le /opt/homebrew
ls -le /usr/local
# 2. Check for immutable/uchg flags (schg = system immutable, uchg = user immutable)
ls -lO /opt/homebrew
ls -lO /usr/local
# If you see 'uchg' or 'schg' on directories, clear them:
sudo chflags -R nouchg,nschg /opt/homebrew 2>/dev/null
sudo chflags -R nouchg,nschg /usr/local 2>/dev/null
# 3. Verify SIP status (must be Enabled for normal operation)
csrutil status
# Expected: "System Integrity Protection status: enabled."
# 4. Check for quarantine attributes on brew binary
xattr -l /opt/homebrew/bin/brew 2>/dev/null | head -5
# If com.apple.quarantine present, strip it:
xattr -d com.apple.quarantine /opt/homebrew/bin/brew 2>/dev/null
# 5. Final verification
brew doctor 2>&1 | head -20
Interpretation: ls -le showing no lines after the permission string means ACLs are clean. ls -lO showing only - or uarch (no uchg/schg) means no immutable flags. SIP must remain enabled; disabling it is not a supported Homebrew configuration.

4. Diagnostic & Operating Parameter Matrix
| Diagnostic Indicator / Check | Expected Normal State | Fault Alert Threshold | Verified Resolution Target |
|---|---|---|---|
ls -ld /opt/homebrew Owner:Group |
youruser:admin (e.g., jdoe:admin) |
root:wheel, root:admin, or _unknown:admin |
Recursive chown -R "$(whoami):admin" applied; verified by ls -ld |
ls -le /opt/homebrew ACL presence |
No + suffix; no ACL lines printed |
+ suffix present or 0: group:everyone deny write entries |
chmod -R -N /opt/homebrew executed; ls -le clean |
ls -lO /opt/homebrew Flags |
No uchg, schg, uappnd, sappnd |
Any immutable/append-only flag on directories | chflags -R nouchg,nschg /opt/homebrew cleared; ls -lO clean |
brew doctor Output |
“Your system is ready to brew.” or only non-critical warnings | “Permission denied @ dir_s_mkdir”, “Not writable:”, “Broken symlinks” | Zero permission-related errors after Steps 02–05 |
which brew / brew --prefix |
/opt/homebrew/bin/brew / /opt/homebrew |
/usr/local/bin/brew or brew not found |
Shell config contains single eval "$(/opt/homebrew/bin/brew shellenv)"; exec $SHELL -l fixes |
csrutil status |
enabled |
disabled or enabled (Custom Configuration) |
Re-enable SIP via Recovery Mode if disabled; Homebrew does not require SIP off |
5. Frequently Asked Questions (FAQ)
Why did my Homebrew permissions break on Mac mini M1 after migrating from an Intel Mac?
Migration Assistant copies /usr/local (Intel Homebrew path) but not /opt/homebrew (Apple Silicon path). If you then installed Homebrew natively on M1, you have two prefixes with mixed ownership. The Intel /usr/local files often retain the old UID/GID, while the new /opt/homebrew gets created with correct ownership—until you accidentally sudo brew or run an installer that uses sudo. Fix: apply Step 02 to both paths, then brew doctor.
I see “Permission denied @ rb_sysopen” when running brew update. Is my disk failing?
Almost certainly not. This is a classic POSIX permission/ACL mismatch on /opt/homebrew/.git or /opt/homebrew/Library/Taps. The .git directory is owned by root because a past sudo git or sudo brew update ran. Run Step 02 (recursive chown + chmod -N) and then brew update again. Disk failure would show I/O errors in dmesg or Console.app, not permission denials on specific Homebrew paths.
Can I just chmod 777 /opt/homebrew to make the errors go away quickly?
Absolutely not. 777 makes every file and directory world-writable. Any compromised process or malicious script can then inject code into your Homebrew formulas, binaries, or shell environment. This is a critical security vulnerability on a multi-user Mac or any network-connected device. The correct fix (Step 02) takes 15 seconds and preserves the intended security model: your admin user owns the prefix, group admin has read/execute, others have read/execute only.
Do I need to reinstall Homebrew from scratch if brew doctor still complains after these steps?
Rarely. Before reinstalling, run the full Step 05 checklist (ACLs, flags, quarantine, SIP). 99% of “persistent” cases are a stray uchg flag on a single directory (often /opt/homebrew/var/homebrew/locks) or a quarantine attribute on the brew binary itself from a manual download. If brew doctor is clean but a specific formula fails, run brew uninstall --force <formula> && brew install <formula>. Full reinstall (/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" then reinstall) is a last resort and takes 5–10 minutes on M1—acceptable but usually unnecessary.
Share your OS version, device model, and exact error code in our independent peer Q&A rooms.
Comments