If you get a brew error, “usr/local is not writable. You should change the ownership and permissions of /usr/local back to your user account:”
Enter into the terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
And it should solve the problem