How to fix macOS usr/local is not writable

This simple post should fix the “usr/local is not writable” issue with homebrew.

Whilst on holiday I needed to use an old MacBook to crack on with some work. In order to do so I had to install the latest version of ansible, but encountered the permissions error “usr/local is not writable”. I found uninstalling and reinstalling homebrew fixed the issue.

Here are the steps I took (which will also update Xcode, if required):
1) Uninstall homebrew:

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

2) Reinstall homebrew:

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

3) Install ansible:

$ brew install ansible

That’s it!

Aside: Before uninstalling homebrew you could try chowning the usr/local

Before trying the above I tried, to no avail, just changing the ownership of the local dir (as described here), but this didn’t work for me. Feel free to try it:

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

Reply