Mac 中的 brew install git 错误:无法符号链接 share/man/man5/gitattributes.5

Nyx*_*nyx 8 git macos homebrew github atlassian-sourcetree

尝试git使用我的 Mac 系统(High Sierra 10.13.3)更新

brew install git
Run Code Online (Sandbox Code Playgroud)

这给出了输出

$ brew install git
==> Downloading https://homebrew.bintray.com/bottles/git-2.16.2.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring git-2.16.2.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/man5/gitattributes.5
/usr/local/share/man/man5 is not writable.

You can try again using:
  brew link git
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions and functions have been installed to:
  /usr/local/share/zsh/site-functions

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/git
==> Summary
  /usr/local/Cellar/git/2.16.2: 1,496 files, 34.5MB
Run Code Online (Sandbox Code Playgroud)

但是,您可以看到它的brew link步骤有问题。尝试通过运行来修复它

brew link git
brew link --overwrite git
brew link --force git
Run Code Online (Sandbox Code Playgroud)

给出同样的错误

Linking /usr/local/Cellar/git/2.16.2... 
Error: Could not symlink share/man/man5/gitattributes.5
/usr/local/share/man/man5 is not writable.
Run Code Online (Sandbox Code Playgroud)

有没有人也遇到过这种情况并设法修复它?


Mac 的用户和组

在此处输入图片说明

输出

在此处输入图片说明

Ort*_*kni 5

您必须使用以下方法修复权限:

sudo chown -R "$USER":admin /usr/local
sudo chown -R "$USER":admin /Library/Caches/Homebrew
Run Code Online (Sandbox Code Playgroud)

如果您是系统上唯一的自制软件用户,那么它效果很好。如果第三方工具正在等待其他权限,则可能会导致问题/usr/local。但是,我使用此设置多年没有出现任何问题。请参阅如何修复自制权限?了解详情。

但为此您必须拥有管理计算机的权限。在“系统偏好设置”->“用户和组”中,您的用户应选中“允许用户管理此计算机”复选框。