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

问题描述 投票:20回答:5

嗨,我刚试过在我的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

我怎么解决这个问题?

macos git github homebrew
5个回答
52
投票

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


9
投票

从高山脉,chown/usr/local是不允许的。但是,您仍然可以更改/usr/local中子目录的权限。

在我的情况下,我不得不在Frameworks/usr/local创建sudo chown -R $(whom) Frameworks。之后是brew doctor所说的。

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

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


7
投票

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

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

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

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


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 

这也解决了你的错误吗?


0
投票

我做了什么brew doctor推荐,它帮助:

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

MacOS 10.14.4

© www.soinside.com 2019 - 2024. All rights reserved.