ThorneLabs

libpng Not Symlinking When Installing ImageMagick on OS X Yosemite


After upgrading from OS X Mavericks to OS X Yosemite, I attempted to install ImageMagick from Homebrew, but encountered an error when brew was trying to install the libpng dependency.

The error encountered was:

[20:32:21][user@workstation][~] brew install libpng
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.6.14.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/libpng-1.6.14.yosemite.bottle.tar.gz
==> Pouring libpng-1.6.14.yosemite.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/png.5
/usr/local/share/man/man5 is not writable.

You can try again using:
  brew link libpng
==> Summary
/usr/local/Cellar/libpng/1.6.14: 17 files, 1.2M

I tried several of the potential fixes in an older StackOverflow thread about OS X Lion trouble with ImageMagick, but nothing worked.

I finally tried Jonghee Park’s suggestion to correct permissions.

Sure enough, the permissions for the man5 folder in /usr/local/share/man were incorrect:

[20:34:12][user@workstation][index_page] ls -al /usr/local/share/man
total 8
drwxr-xr-x  19 user  admin   646 Nov 23 20:34 .
drwxr-xr-x  11 user  admin   374 Nov 23 20:29 ..
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 de
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 es
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 fr
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 hr
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 hu
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 it
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 ja
drwxr-xr-x  48 user  admin  1632 Nov 23 20:32 man1
drwxr-xr-x   3 root  wheel   102 Aug 31 00:00 man5
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 pl
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 pt_BR
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 pt_PT
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 ro
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 ru
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 sk
-rw-r--r--   1 root  admin  1544 Nov 21 00:55 whatis
drwxr-xr-x   3 user  admin   102 Oct 19 17:29 zh

The fix was as simple as running the following command:

sudo chown -R user:admin /usr/local/share/man/man5

And, re-running brew link libpng.

This problem did not occur with a fresh install of OS X Yosemite.