在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:32:02  来源:igfitidea点击:

Install git via homebrew on mac osx 10.10 results in: Error: Permission denied - /usr/local/lib/perl5/site_perl/5.18.2

macosgitgithubhomebrew

提问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/localand then: brew link --overwrite gitIt 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, chownof /usr/localis 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 Frameworksin /usr/localand sudo chown -R $(whom) Frameworks. After that follow what brew doctorsays.

就我而言,我必须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 deniederror on install of gituntil I cleaned things up:

permission deniedgit我清理之前,我在安装时遇到了类似的错误:

$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 doctorrecommended 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