After upgrading weechat using Homebrew, brew says formula built but weechat was not symlinked

homebrewpermissionsymlink

I installed weechat 1.9(an IRC client) with brew a long time ago. Today I was trying to update the program to the latest version with 'brew upgrade weechat'. The whole upgrading process was successful, only with an error at the end that says

Error: The brew link step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/de/man1/weechat-headless.1
/usr/local/share/man/de/man1 is not writable.

I first figured it might be for the reason that the /usr/local/share/man/de/man1 directory was not writable due to the user that homebrew runs as was not given enough access privilege. I then changed the group owner of the directory from 'wheel' to 'admin' which is the owner of most of the directories generated by homebrew. But it didn't work.

I tried to uninstall and reinstall weechat, it's still the same error.

Best Answer

Just fixed this same issue on my system!

From this related thread about a similar brew link issue with nmap:

I'd wiped /usr/local/ before installing brew, so was unsure about this. Realised that MacTeX installs its stuff in there too by default, causing this issue.

Apparently some software will write to that folder using root privileges on install so there is an ownership issue here.

To fix:

  1. ls -la /usr/local/share/man/
  2. Identify which directories require ownership permission changes
    • Using /usr/local/share/man/de/ as an example, it was owned by user "root" in group "wheel" prior to the fix, whereas we want it to be owned by your user (output of whoami) in group "admin"
  3. Recursively change ownership of the directory and all sub-directories thereof: sudo chown -R $(whoami):admin /usr/local/share/man/de/
  4. Attempt linking again: brew link weechat

The above steps fixed the issue for me!