“Failure while executing” error when trying to install GCC

gcchomebrewterminalxcode

I've followed the instructions of the both the accepted answer to this question as well as the other suggestions, How do I install GCC via Homebrew?. But all I get is the following message when I run the brew install gcc command:

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo. Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool

And if I try to run the brew install gcc command with sudo:

Error: Cowardly refusing to `sudo brew install` 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.

Why is this happening and what can I do to get around it? And yes, I've got the latest version of xcode.

Best Answer

brew doesn't need root permission. Do you have Xcode installed? If you do have you opened it up and agreed to the license?