在mac osx 10.10上通过自制软件安装git导致:错误:权限被拒绝 - /usr/local/lib/perl5/site_perl/5.18.2

时间:2014-11-07 20:46:02

标签: macos git github homebrew

您好我刚试过在我的Mac上通过自制软件安装git - 出了点问题。我安装了mac app的github,但我尝试删除它。我系统中当前的git版本是:

Nielsk@~: $ git --version
git version 1.9.3 (Apple Git-50)

如果我尝试通过自制软件安装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

我该如何解决这个问题?

5 个答案:

答案 0 :(得分:52)

我也遇到了同样的问题。我认为我们应该更改可读权限,以确保所有目录都可以被" all"读取。所以我尝试了命令:sudo chown -R $USER:admin /usr/local 然后:brew link --overwrite git它适用于我,希望它也适合你。

答案 1 :(得分:9)

来自High Sierra,不允许chown /usr/local。但是,您仍然可以更改/usr/local中的子目录的权限。

就我而言,我必须在Frameworks/usr/local中创建sudo chown -R $(whom) Frameworks。然后按照brew doctor的说法进行操作。

更好的方法是根据需要创建子目录并运行

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

答案 2 :(得分:7)

对于使用新El Capitan OS的用户,您需要更新权限:

打开终端并输入以下命令:

$ sudo chown -R $(whoami):admin /usr/local 
$ brew doctor 
$ brew update
$ brew link --overwrite git

上述解决方案适用于其他brew安装,如节点等。如果您开始安装,只需更换最后一行,但在brew安装过程中遇到错误。

答案 3 :(得分:5)

我安装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 

这也解决了你的错误吗?

答案 4 :(得分:0)

我按照brew doctor的建议做了,它有所帮助:

sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin

MacOS 10.14.4