Brew error: Could not symlink, path is not writable

PackageHomebrew

Package Problem Overview


When I try to install a library with homebrew (brew install aLibrary), I got the following error:

Could not symlink lib/pkgconfig/aFile
/usr/local/lib/pkgconfig is not writable.

What should I do?

There are several questions and answers (1,2,etc.) concerning this brew error, this is an attempt to make a general question as suggested here.

Package Solutions


Solution 1 - Package

As explained here by Rick:

Start with brew doctor which will show you errors with your brew setup.

You might see something like this: "Warning: /usr/local/lib/pkgconfig isn't writable."

It will give you the advice that: "You should probably chown /usr/local/lib/pkgconfig".

This means: sudo chown -R $(whoami) /usr/local/lib/pkgconfig

Then you will need to link the files with this: brew link yourLibrary

If this does not work hopefully the output of brew doctor will give you enough to continue the search.

Solution 2 - Package

Giant Elk had a great suggestion and this is how I fixed my issue, which in my opinion is the cleanest. Users should not change permissions unless they know the ramifications.

  1. Output your installed packages (via brew) to a text file:

     brew list > brewlist.txt
    
  2. Uninstall brew:

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

     /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  4. Re-install previous packages (edit list if you do not need all packages):

     brew install $(< brewlist.txt )
    

Solution 3 - Package

Use the following.

$ brew doctor

message will display error links to prune. If any found, run next option.

$ brew prune

once these are removed, proceed to link them agian

$ brew link python

Solution 4 - Package

I uninstalled brew, re-installed, then the issues went away.

Solution 5 - Package

You should simply give the permission to your account by running this command on terminal.

sudo chown -R $(whoami) (path)

In your case: sudo chown -R $(whoami) lib/pkgconfig/aFile /usr/local/lib/pkgconfig

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionarthur.swView Question on Stackoverflow
Solution 1 - Packagearthur.swView Answer on Stackoverflow
Solution 2 - PackageRSchroederView Answer on Stackoverflow
Solution 3 - PackageeltechnochamoView Answer on Stackoverflow
Solution 4 - PackageGiant ElkView Answer on Stackoverflow
Solution 5 - PackagedefconView Answer on Stackoverflow