sudo brew - Do not Try and How to Recover

If someone tries to use brew with sudo, a warning will show up:

1
Error: Cowardly refusing to `sudo brew [option]`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

Well, you may continue to run it after use sudo -i, but you will laterly have many problems. While brew is running under root, it will change the ownership of folders like /usr/local/include to root. And later if you want to run commands like brew link, you will fail:
1
Error: Could not symlink include/gdbm.h
/usr/local/include is not writable.

To recover this, you must change the ownership back:
1
sudo chown -R $(whoami) /usr/local/include
sudo chown -R $(whoami) /usr/local/lib

And remember: Do not try sudo brew the next time.