Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew update fails with "Permission denied" error

Tags:

macos

homebrew

I have been trying to upgrade my brew installation on Mac and it always fails with the following error:

Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

I do not want to run brew as sudo, but is there a way to fix this error? I'm not able to install Python3 which is my ultimate goal. Is there another way to install Pythion3 on Mc other than brew? Is there any resolution for this problem here?

EDIT: I tried to remove python3 and tried to re install it again and this time it fails with some other message:

==> Pouring python-3.6.5.high_sierra.bottle.1.tar.gz
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
like image 1000
joesan Avatar asked May 10 '18 07:05

joesan


People also ask

What is Homebrew tap?

Taps (Third-Party Repositories) The brew tap command adds more repositories to the list of formulae that Homebrew tracks, updates, and installs from. By default, tap assumes that the repositories come from GitHub, but the command isn't limited to any one location.

What is brew update?

brew update and upgrade brew update updates the above downloaded git repository with the latest code from GitHub. brew upgrade updates the actual packages to match the versions in the updated local git repository.


2 Answers

Try to change owner of /usr/local.

if you use macOS High Sierra or higher try this command:

sudo chown -R $(whoami) $(brew --prefix)/*

if you use macOS Sierra or lower:

sudo chown -R $(whoami) /usr/local
like image 89
Andrew Vergunov Avatar answered Oct 21 '22 01:10

Andrew Vergunov


In Mac OSX Mojave, installing Python3, I solved this issue by the following:

sudo mkdir /usr/local/Frameworks
sudo chown -R user:group /usr/local/Frameworks/
brew link python

Where user and group are specified as set by the OS. You can find out what user/group values should be by doing:

 ls -al /usr/local

And then python3 was successfully installed:

> python3
Python 3.7.2 (default, Feb 12 2019, 08:15:36) 
[.Clang 10.0.0 (clang-1000.11.45.5)] on darwin
like image 21
saswanb Avatar answered Oct 21 '22 02:10

saswanb