How to Fix Homebrew Permission Denied Errors on Mac

Learn how to fix Homebrew permission denied errors on Mac by adjusting ownership and permissions on specific directories safely and effectively.

Share
Homebrew permission denied on Mac error displayed in terminal window

Mac users encountering 'permission denied' errors with Homebrew often face confusion about the cause and solution. This issue typically arises because Homebrew directories like /usr/local/Cellar on Intel Macs or /opt/homebrew/Cellar on Apple Silicon Macs are owned by root instead of the current user. The correct fix involves adjusting ownership and permissions only on the specific directories flagged by Homebrew’s diagnostics.

Running brew commands with sudo can worsen these problems by changing ownership to root, so avoiding sudo with brew commands is critical. A reliable Homebrew permission denied on Mac fix begins with identifying the exact directories causing the issue and applying targeted ownership changes followed by permission adjustments.

It is also essential to have the Xcode Command Line Tools installed, as Homebrew requires them to build formulae from source. Installing Xcode alone does not satisfy this requirement and can trigger permission and build errors.

Settings, menu paths and limits here were checked against Homebrew Documentation, Simplified Guide, ADHDecode (full list at the end) in November 2026.

Identify which fix fits your Mac and Homebrew setup

Homebrew installs to different default locations depending on the Mac's processor type. On Apple Silicon Macs, it installs under /opt/homebrew, while Intel Macs use /usr/local. This distinction determines which directories are involved when permission denied errors appear.

Permission issues can be isolated to specific directories or affect the entire Homebrew installation. For example, errors on directories like /opt/homebrew/Cellar or /usr/local/Cellar often mean those directories have incorrect ownership, typically root instead of the current user. These cases call for targeted ownership fixes.

If permission problems are widespread, often caused by running brew commands with sudo, a full uninstall and reinstall of Homebrew is necessary. This process requires backing up installed formulae, uninstalling Homebrew completely using the official script, then reinstalling Homebrew and restoring the formulae.

SituationFix OptionKey Fact
Apple Silicon Mac with permission errors on specific directoriesFix ownership and permissions on those directories onlyHomebrew installs to /opt/homebrew; errors localized to directories
Intel Mac with permission errors on specific directoriesFix ownership and permissions on those directories onlyHomebrew installs to /usr/local; errors localized to directories
Any Mac with widespread permission issues caused by sudo useBackup formulae, uninstall, then reinstall Homebrew and formulaeWidespread ownership problems due to sudo misuse
  1. Confirm the Mac processor type (Apple Silicon or Intel) using System Information.
  2. Note the Homebrew install location: /opt/homebrew for Apple Silicon, /usr/local for Intel.
  3. Assess whether permission denied errors occur on specific directories or across many Homebrew components.
  4. If errors are directory-specific, prepare to fix ownership only on those directories.
  5. If errors are widespread and linked to running brew with sudo, plan to back up installed formulae and perform a full uninstall and reinstall.

Use brew doctor to find which Homebrew directories have permission problems

Diagnosing Homebrew permission issues starts by running brew doctor. This command scans the Homebrew installation and reports directories that the current user cannot write to. Identifying the exact problematic paths prevents unnecessary or broad permission changes, which can cause security risks or system instability.

  1. Open the Terminal app on the Mac.
  2. Type brew doctor and press Enter.
  3. Wait for the command to complete. If permission problems exist, the output will list directories with non-writable permissions.

The output might show lines like:

Warning: /usr/local/Cellar is not writable. You should change ownership.
Warning: /opt/homebrew/Cellar is not writable. You should change ownership.

These warnings indicate permission errors where the directories are likely owned by root or another user instead of the current user. Fixing only these specific directories reduces the chance of causing permission problems elsewhere in the Homebrew tree.

Running brew doctor provides a focused diagnosis. Use its output to guide ownership fixes precisely on the affected directories. Avoid guessing or applying recursive ownership fixes to all Homebrew directories, as this can break the installation.

  • Run brew doctor in Terminal
  • Review output for directories labeled as not writable
  • Note exact directory paths reported by brew doctor

Fix ownership and permissions only on the problematic Homebrew directories

When Homebrew reports permission denied errors on specific directories, it is essential to address ownership and permissions only on those affected paths. Running brew doctor identifies which directories lack proper write access. Applying fixes broadly to the entire Homebrew installation folder, such as /usr/local on Intel Macs or /opt/homebrew on Apple Silicon Macs, risks breaking multi-user access and system boundaries.

Begin by changing ownership recursively on just the directories flagged by brew doctor. Use a command like sudo chown -R $(whoami) /opt/homebrew/Cellar to assign ownership safely. Follow this by restoring write permission to the user with chmod u+w /opt/homebrew/Cellar. These steps ensure the current user can write to Homebrew directories without compromising other users’ permissions.

Avoid running ownership changes on the entire /usr/local or /opt/homebrew folders because these locations often hold files shared among users. Recursive ownership changes at this level can cause permission conflicts and unintended access problems. Instead, focus exclusively on directories that brew doctor identifies as problematic to maintain a stable and secure Homebrew environment.

  1. Run brew doctor and note directories with permission issues.Success: The command lists specific directories needing fixes.
  2. Change ownership recursively on each reported directory.Example: sudo chown -R $(whoami) /opt/homebrew/Cellar This reassigns ownership to the current user for that directory.
  3. Restore write permission to the user on those directories.Example: chmod u+w /opt/homebrew/Cellar This enables the user to write files and folders inside.
  • Run brew doctor to identify problematic Homebrew directories.
  • Use sudo chown -R $(whoami) only on those directories.
  • Apply chmod u+w to restore write permissions on the same directories.

Permission denied errors during Homebrew operations can stem from cached files or directories with incorrect ownership or restrictive permissions. These issues often occur when cache files become owned by root or another user, blocking Homebrew’s access. Clearing the Homebrew cache and resetting its permissions restores proper access and prevents these errors from recurring.

  1. Remove the Homebrew cache files by running sudo rm -rf ~/Library/Caches/Homebrew/. This deletes all cached downloads and temporary files, eliminating any corrupted or root-owned items. If successful, no error messages will appear.
  2. Reset ownership of the cache directory and all its contents with sudo chown -R $(whoami):admin ~/Library/Caches/Homebrew/. This assigns the current user and the admin group as owners, allowing write access to Homebrew processes.
  3. Set correct permissions by running chmod -R 755 ~/Library/Caches/Homebrew/. This grants read, write, and execute permissions to the owner and read/execute permissions to group and others, ensuring proper access control.

After these steps, Homebrew should no longer encounter permission denied errors related to its cache. Avoid running brew commands with sudo to prevent reintroducing ownership problems. Clearing and resetting cache permissions targets only the cache area, minimizing risk to the overall Homebrew installation.

  • Remove Homebrew cache files with sudo rm -rf
  • Reset ownership on the cache directory
  • Apply correct permissions to the cache directory

Avoid running brew commands with sudo to prevent permission problems

Homebrew is designed to operate without elevated privileges. Running brew commands prefixed with sudo changes file and directory ownership to root, disrupting Homebrew’s expected permissions. This causes permission denied errors for the standard user because root ownership restricts regular user access.

Avoid running brew commands with sudo to prevent permission problems – Homebrew permission denied on Mac fix

When sudo is used, files and directories become inaccessible to Homebrew running as a normal user. This breaks Homebrew’s functionality and leads to repeated permission issues. Avoiding sudo with brew commands preserves correct ownership and prevents permission conflicts.

If sudo was used mistakenly, ownership must be restored to the normal user on affected directories. This ensures Homebrew can read and write files as intended without permission errors.

  1. Identify Homebrew directories owned by root by running ls -l /opt/homebrew on Apple Silicon Macs or ls -l /usr/local on Intel Macs. The output should show the current owner and group.
  2. Restore ownership recursively to the current user by running sudo chown -R $(whoami):admin /opt/homebrew or sudo chown -R $(whoami):admin /usr/local depending on the Mac type. This returns ownership from root to the user.
  3. Verify ownership changes by listing the directories again to confirm the user now owns the files and folders, eliminating root ownership.

Grant Full Disk Access to Terminal apps to fix permission denied errors caused by macOS privacy protections

macOS includes System Integrity Protection (SIP) and privacy controls that can block Terminal apps from accessing certain files, causing permission denied errors unrelated to file ownership or permissions. These errors often show as “Operation not permitted” when running Homebrew commands or scripts. Granting Full Disk Access to the Terminal app allows it to bypass these privacy restrictions safely.

  1. Open the Apple menu and select System Settings.
  2. Navigate to Privacy & Security and then choose Full Disk Access.
  3. Click the Add button (usually a plus icon) and select the Terminal app located in Applications > Utilities. This adds Terminal to the list of apps allowed full disk access.
  4. Quit the Terminal app completely and then reopen it to apply the changes.
  5. Run the previously failing Homebrew commands again to confirm permission denied errors no longer occur.

This process addresses permission issues caused by macOS privacy protections, not by file ownership problems. Without granting Full Disk Access, Terminal apps may be blocked from accessing critical Homebrew folders or system files, even if permissions appear correct. Always quit and reopen Terminal after granting access to ensure the changes take effect.

  • Open System Settings and go to Privacy & Security → Full Disk Access
  • Add Terminal app from Applications → Utilities
  • Quit and reopen Terminal to activate the new permission

Fix 'zsh: permission denied' errors when running scripts or commands

When encountering zsh: permission denied errors while running scripts or commands, the most common cause is missing execute permissions on the script file. Unix-based systems like macOS require scripts to have execute permission bits set before they can be run directly in the shell. Without this, the shell refuses execution to protect against unauthorized or accidental script runs.

To resolve this, add execute permission to the script using the command chmod +x script.sh, replacing script.sh with the actual script filename. This command changes the file mode to make it executable by the user, allowing the shell to run it without errors. Once done correctly, the permission denied error should no longer occur when invoking the script directly.

Alternatively, if changing permissions is not desirable or possible, run the script by explicitly invoking its interpreter. For example, use zsh script.sh to execute the script with the zsh shell, bypassing the need for execute permission on the script file itself. This method is useful for quick tests or when file permissions cannot be modified.

  1. Check the script file for execute permission with ls -l script.sh. If the execute bit is missing, proceed to step 2.
  2. Run chmod +x script.sh to add execute permission. After this, running ./script.sh should work without permission errors.
  3. If not changing permissions, run the script with its interpreter explicitly, such as zsh script.sh, to avoid permission issues.

Uninstall and reinstall Homebrew if permission problems are widespread or caused by sudo misuse

When permission problems affect many parts of Homebrew or stem from running brew commands with sudo, it is best to fully uninstall and reinstall Homebrew. This approach prevents further damage from lingering incorrect permissions and restores a clean installation.

  1. Backup the list of installed formulae by running brew list > ~/brew_formulae_backup.txt. This saves a record of all installed packages for later reinstallation.
  2. Use the official uninstall script to remove Homebrew completely. This script deletes Homebrew files and directories, removing permission issues tied to the current setup. The script can be run with a command like /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)". After completion, Homebrew should no longer be present.
  3. Reinstall Homebrew using the official installation script. This ensures a fresh install with correct permissions and ownership. The installation command is typically /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". The process sets up Homebrew in the proper location for the Mac’s architecture.
  4. Restore the previously installed formulae by running xargs brew install < ~/brew_formulae_backup.txt. This reinstalls all packages from the backup list, returning Homebrew to its prior state without retained permission problems.

This full uninstall and reinstall process is necessary only when targeted fixes fail due to widespread permission errors or sudo misuse. Backing up installed formulae first preserves the user’s environment and avoids manual reinstallations.

Common mistakes to avoid when fixing Homebrew permission denied errors

Changing ownership or permissions recursively on entire directories like /usr/local, /opt/homebrew, or /Applications without identifying the specific problematic paths leads to broken Homebrew setups and potential system issues. These directories serve multiple purposes and users, so blanket changes disrupt access and can cause unpredictable behavior.

Running Homebrew commands with sudo is a critical mistake. It causes files and folders to become owned by the root user, which breaks Homebrew’s expected permission model. Homebrew is explicitly designed to operate without elevated privileges, so using sudo on brew commands will generate persistent permission denied errors.

Blindly deleting or modifying all files within Homebrew directories to fix permission issues risks severe data loss and corrupts the installation. Instead, rely on targeted fixes guided by tools like brew doctor that identify exact problem locations. Overzealous file removal or changes undermine Homebrew’s functionality.

Using sudo combined with shell redirection like sudo echo 'text' >> file does not work as intended because the shell opens the file before sudo elevates privileges. This results in permission denied errors even if sudo is prepended. The correct method is to pipe the output through sudo tee -a file, which properly escalates privileges for writing.

How to verify that Homebrew permission issues are fixed

After applying fixes, start by running brew doctor. This command diagnoses Homebrew installation issues, including permission problems. A successful fix is confirmed when brew doctor reports no permission warnings or directory access errors. The output should state that the system is ready to brew and show no complaints about directory writability.

How to verify that Homebrew permission issues are fixed – Homebrew permission denied on Mac fix

Next, test common Homebrew commands such as brew update or installing a small package with brew install. These commands should complete without producing any permission denied errors. Successful execution means Homebrew can read, write, and execute in the necessary directories.

Finally, manually check ownership and permissions on directories that previously caused problems. Ensure these directories are owned by the current user and have appropriate write permissions. This confirms that targeted fixes were applied correctly and prevents future permission issues.

  1. Run brew doctor and confirm no permission warnings appear.
  2. Execute brew update or brew install to verify no permission errors occur.
  3. Inspect ownership and permissions on previously problematic Homebrew directories to ensure they belong to the current user and allow writing.

Frequently asked questions

How to uninstall homebrew on mac?

This script can be executed by downloading it from Homebrew's GitHub repository or running a command in Terminal that fetches and runs it directly. Care should be taken not to manually delete Homebrew directories, as this may leave residual files and cause issues if Homebrew is reinstalled later.

How to use homebrew on macos?

Homebrew is used via the Terminal application by typing commands starting with brew. It installs, updates, and manages software packages by downloading precompiled binaries or source code. After installing Homebrew, running brew help shows available commands and options. Using it with proper permissions and without sudo avoids most permission issues.

Is homebrew on mac safe?

Homebrew is generally safe when installed and used correctly, as it isolates its files within designated directories depending on the Mac architecture. However, using sudo with Homebrew commands or changing permissions too broadly can compromise system security and stability. It is safest to follow targeted permission fixes and avoid broad ownership changes or running brew commands as root.

Common mistakes to avoid when fixing Homebrew permission denied errors

  • Changing ownership or permissions on the entire Homebrew installation directory without first identifying problematic directories. This can cause broader permission issues and security risks. Always run brew doctor first to target fixes.
  • Using sudo to run Homebrew commands. This often creates files owned by root, leading to mixed ownership and further permission denied errors. Avoid sudo with brew entirely.
  • Ignoring macOS privacy protections like Full Disk Access, which can block Terminal apps from accessing certain folders even if permissions appear correct. Always check and grant Full Disk Access under System Settings > Privacy & Security.
  • Attempting to fix permissions in the wrong order. For example, resetting ownership before fixing cache permissions can cause errors, so follow the recommended sequence strictly.
  • Overlooking zsh: permission denied errors caused by script file permissions rather than Homebrew itself. Check executable flags on scripts and adjust with chmod +x as needed.

Essential steps to resolve Homebrew permission denied issues

When this guide is not enough and other help is needed

For the most reliable results, follow the checklist steps carefully, ensuring that ownership and permissions are corrected only where necessary and that macOS privacy settings support Homebrew's operation. Maintaining the correct setup avoids recurring permission issues and keeps Homebrew functioning smoothly.

Sources

See also: Microsoft Word Keeps Crashing on Mac: How to Fix It Step-by-Step · How to Fix Excel Not Opening Files on Mac · How to Fix ‘An Error Occurred While Preparing the Installation’ on Mac · How to Fix Rosetta Not Installing or Working on Mac