MacOS – brew link error

homebrewmacos

many times I do brew install and I keep getting error unable to link, and brew doesnt give what it is not able to link to, it does tell what it is able to, time back I manually did it but now I forgot, however I want to fix this issue of linking error from brew once and for all,

does anyone have any clue whats the cause and how to fix it forever ?

macHost:Volumes userName$ brew install gqview
Error: You must `brew link libtiff libpng` before gqview can be installed

macHost:Volumes userName$ brew link libtiff libpng
Linking /usr/local/Cellar/libtiff/4.0.6... 
Error: Could not symlink share/man/man3/TIFFClose.3tiff
/usr/local/share/man/man3 is not writable.

Best Answer

Make sure /usr/local writable by userName for brew installation to work. Trying running this:

sudo chown -R $(whoami):admin /usr/local