Homebrew install fails while copying files

自作多情 提交于 2019-12-08 16:00:43

问题


I run this:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

I get prompt:

==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

After I click "return"(enter button) I get this error:

==> Downloading and installing Homebrew...
fatal: cannot copy '/usr/local/git/share/git-core/templates/hooks/pre-receive.sample' to '/usr/local/Homebrew/.git/hooks/pre-receive.sample': Permission denied
Failed during: git init -q

Any ideas what kind of error I am facing and what can be done? It is not really clear for me as it is first time I am facing something like this.


回答1:


You are getting permission denied when downloading the files into /usr/local.

This folder often belongs to root. This is a known issue with brew. Fix it by doing

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

and then re-run the installer.




回答2:


I could get it working with

sudo chown -R $USER /usr/local

thanks to @joran for suggesting this in comments




回答3:


If nothing works, then just uninstall and install home-brew again.

Uninstall command:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Install command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"



回答4:


I ran into the error message issue trying to update Brew via another Mac user. When I tried entering the above sudo chown -R $USER /usr/local I got:

chown: /usr/local: Operation not permitted

I found this sudo chown -R $(whoami) $(brew --prefix)/* which allowed me to perform install of brew for separate Mac user.



来源:https://stackoverflow.com/questions/40592463/homebrew-install-fails-while-copying-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!