在 mac osx 10.10 上通过自制软件安装 git 导致:错误:权限被拒绝 - /usr/local/lib/perl5/site_perl/5.18.2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26809799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install git via homebrew on mac osx 10.10 results in: Error: Permission denied - /usr/local/lib/perl5/site_perl/5.18.2
提问by Niels Kristian
Hi I just tried installing git via homebrew on my mac - something is wrong. I had the github for mac app installed, but I tried removing that. The current git version in my system is:
嗨,我刚刚尝试在我的 Mac 上通过自制软件安装 git - 出了点问题。我安装了 github for mac 应用程序,但我尝试删除它。我系统中当前的 git 版本是:
Nielsk@~: $ git --version
git version 1.9.3 (Apple Git-50)
This is what happens if I try to install git via homebrew:
如果我尝试通过自制软件安装 git,就会发生这种情况:
Nielsk@~: $ brew install git
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-2.1.3.y
######################################################################## 100,0%
==> Pouring git-2.1.3.yosemite.bottle.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
/usr/local/bin/git-credential-osxkeychain
The 'contrib' directory has been installed to:
/usr/local/share/git-core/contrib
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
zsh completion has been installed to:
/usr/local/share/zsh/site-functions
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied - /usr/local/lib/perl5/site_perl/5.18.2
Error: Permission denied - /usr/local/lib/perl5/site_perl/5.18.2
How can I solve this?
我该如何解决这个问题?
回答by Jonyzfu
I also met the same issue. I think we should change the readable permission to make sure any of the directories is readable by "all". So I tried the command: sudo chown -R $USER:admin /usr/local
and then: brew link --overwrite git
It works for me, hope it will also work for you.
我也遇到了同样的问题。我认为我们应该更改可读权限以确保任何目录都可以被“所有”读取。所以我尝试了命令:sudo chown -R $USER:admin /usr/local
然后:brew link --overwrite git
它对我有用,希望它也对你有用。
回答by Ryan
From High Sierra, chown
of /usr/local
is not allowed. However you can still change permission the sub directories in /usr/local
.
从高塞拉利昂,chown
中/usr/local
是不允许的。但是,您仍然可以更改/usr/local
.
In my case, I had to create Frameworks
in /usr/local
and sudo chown -R $(whom) Frameworks
. After that follow what brew doctor
says.
就我而言,我必须Frameworks
在/usr/local
和 中创建sudo chown -R $(whom) Frameworks
。之后按照brew doctor
说的去做。
The better way is to create subdirectory whatever you need and run
更好的方法是根据需要创建子目录并运行
sudo chown -R $(whoami) $(brew --prefix)/*
sudo chown -R $(whoami) $(brew --prefix)/*
回答by Jen C
For those with the new El Capitan OS, you'll need to update your permissions:
对于使用新 El Capitan 操作系统的用户,您需要更新您的权限:
Open Terminal and type the following commands:
打开终端并输入以下命令:
$ sudo chown -R $(whoami):admin /usr/local
$ brew doctor
$ brew update
$ brew link --overwrite git
The above solution will work for other brew installs like node, etc. Just replace the last line if you started the installation but encountered errors during the brew installation.
上述解决方案适用于其他 brew 安装,如 node 等。如果您开始安装但在 brew 安装过程中遇到错误,只需替换最后一行。
回答by mbb
I had a similar permission denied
error on install of git
until I cleaned things up:
permission denied
在git
我清理之前,我在安装时遇到了类似的错误:
$brew doctor
..... << long output of issues, so you run:
$brew prune
$brew doctor
..... << less issues now, so manually clean up
$brew update
$brew install git
Does that address your error as well?
这是否也解决了您的错误?
回答by altumano
I did what brew doctor
recommended and it helped:
我做了brew doctor
推荐的事情,它有帮助:
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
MacOS 10.14.4
macOS 10.14.4