How To Fix Cowardly Refusing to Sudo error in Brew – Mac OS X

It is a common error that users generally encounter when they try to execute a brew command as sudo and shown below is an example of how the error looks like:

Debjit-Sahas-Mac-mini:mcrypt debjit$ sudo brew link mcrypt
Password:
Sorry, try again.
Password:
Error: Cowardly refusing to `sudo brew link`
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.

 

 

First find out what is the current ownership of the installed package of brew (you will need this info in the last step)

ls -al `which brew`

Change the user and group of brew to root and wheel respectively:

sudo chown root:wheel `which brew`

Now execute your brew command as root, for eg. sudo brew link mcrypt. Lastly, revert back the ownership of brew to what you had found out in step 1 above

sudo chown : `chown brew`

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。