8

Tried to update git on my Mac system (High Sierra 10.13.3) using

brew install git

which gives the output

$ 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

However, you can see that it has a problem with the brew link step. Attempting to fix it by running

brew link git
brew link --overwrite git
brew link --force git

gives the same error

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.

Anyone experienced this too and managed to fix it?


Mac's Users and Group

enter image description here

Output

enter image description here

Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

2 Answers2

5

You have to fix the permissions with:

sudo chown -R "$USER":admin /usr/local
sudo chown -R "$USER":admin /Library/Caches/Homebrew

It works well, if you are the only homebrew user on the system. It could cause problems if third party tools are waiting other permissions on /usr/local. But, I use this settings for years without problems. See How to fix homebrew permissions? for details.

But for this you must have the right to administer the computer. In System Preferences -> Users & Groups, your user should have the checkbox "Allow user to administer this computer" checked.

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
4

If you are on High Sierra, the /usr/local is not writable (probably due to changes in SIP) but the contents are. So you just need to modify the commands from the other answer to only target the directories within:

sudo chown -R "$USER":admin /usr/local/*
sudo chown -R "$USER":admin /Library/Caches/Homebrew/*
Caretaker007
  • 146
  • 4