Resetting the permission in /usr/local

Sharing the solution for a permission issue that occurred after a macOS update

Problem

: The following error is thrown when executing the brew cleanup command

Error: Permission denied @ apply2files - /usr/local/lib/node_modules/serverless/node_modules/.bin/detect-libc

Cause

: Reportedly a problem that occurs after upgrading macOS to Mojave 10.14.X or higher

Reference - Homebrew github issuearrow-up-right

Solution

: Execute the following command to reset the permissions granted to /usr/local

sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*

Resolved!

Last updated