13

I've really tried and used any suggestion from repairing, over uninstalling everything, to reinstalling, etc. but no solution works. I'm completely stuck and need help to find a solution! Thanks in advance, Christoph

MacBook-2:~ MyUserName$ brew install git
Warning: git-2.1.3 already installed, it's just not linked
MacBook-2:~ MyUserName$ brew destroy git
Error: Unknown command: destroy
MacBook-2:~ MyUserName$ brew uninstall git
Uninstalling /usr/local/Cellar/git/2.1.3...
MacBook-2:~ MyUserName$ brew install git
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-    2.1.3.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/git-2.1.3.yosemite.bottle.tar.gz
==> 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: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/git-core/contrib
 /usr/local/share/git-core is not writable.

You can try again using:
 brew link git
==> Summary
  /usr/local/Cellar/git/2.1.3: 1342 files, 32M
MacBook-2:~ MyUserName$ brew link git
Linking /usr/local/Cellar/git/2.1.3... 
Error: Could not symlink share/git-core/contrib
 /usr/local/share/git-core is not writable.
bfontaine
  • 18,169
  • 13
  • 73
  • 107
AWChristoph
  • 141
  • 1
  • 4

3 Answers3

29

This is probably an error related to permissions.

Try

sudo chown -R $(whoami) /usr/local/share/

or, if you only need this on the git-core path,

sudo chown -R $(whoami) /usr/local/share/git-core 

might be enough.

Then run

brew link git

again.

mattias
  • 2,079
  • 3
  • 20
  • 27
  • Thanks, but that doesn't help either.... Terminal tells me then: Christophs-MacBook-2:~ AWChristoph$ brew link git Error: No such keg: /usr/local/Cellar/git – AWChristoph Nov 12 '14 at 23:44
  • Seems to be the same issue there, then. Do a `sudo chown -R $(whoami) /usr/local/Cellar/`. – mattias Nov 13 '14 at 07:16
  • @matthias Apparently not, it tells me Linking /usr/local/Cellar/git/2.1.3... Error: Permission denied - /usr/local/lib/perl5/site_perl/5.18.2 – AWChristoph Nov 13 '14 at 19:15
  • 3
    @AWChristoph: I think you kind of miss the point of what we're doing with the chown -R. Every time you stumble upon a new _permission denied_ message, that is because the user who is currently running the `brew` command does not have permission to write to those directories. With that said, for this newest message you posted, you need to do `chown -R $(whoami) /usr/local/lib/perl5/`. But maybe it would be easier to just do `sudo brew link git`. Though, this is normally not recommended. – mattias Nov 13 '14 at 21:19
  • The problem is that I receive this errors chown: /usr/local/lib/perl5//site_perl/Git/I18N.pm: Operation not permitted chown: /usr/local/lib/perl5//site_perl/Git/IndexInfo.pm: Operation not permitted chown: /usr/local/lib/perl5//site_perl/Git/SVN/Editor.pm: Operation not permitted.... -> and more of them – AWChristoph Nov 14 '14 at 08:06
  • Oh, put a `sudo` infront of it. In all cases where you need to change permissions of a directory which is not owned by current user, you need to do `sudo`. So, `sudo chown -R $(whoami) /usr/local/lib/perl5/` should do the trick for ya. – mattias Nov 14 '14 at 08:39
  • 1
    I'm running ZSH, for me it was: `sudo chown -R $(whoami) /usr/local/share/zsh/site-functions`. – originalhat Apr 06 '15 at 15:46
  • @DevinBrown: Instead of `sudo chown -R $(whoami) /usr/local/share/` or `sudo chown -R $(whoami) /usr/local/share/git-core` ? I'll update the answer to also comply with ZSH. – mattias Apr 06 '15 at 19:37
13

Maybe you use sudo to install some application before ,So the owner of dictionary /usr/local/share/ and /usr/local/lib become root

run:

sudo chown -R $(whoami) /usr/local/share/

sudo chown -R $(whoami) /usr/local/lib

and then run:

brew link git
Favoorr
  • 165
  • 5
0

Before changing permissions I would:

Option 1: Try to Uninstall brew

1 ) Save a list of your brew packages:

brew list > my_packages.txt

2 ) Then uninstall brew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

3 ) Re-install brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

4 ) Re-install all your packages:

brew install $(< my_packages.txt )

Option 2:

If that didn't work try running:

brew doctor

Check if errors can be pruned with:

brew prune

Reference.

Rot-man
  • 18,045
  • 12
  • 118
  • 124