5

I am trying to install OpenCV with Homebrew.

After typing

sudo brew install opencv 

I get this error message

Cowardly refusing to sudo brew install

How can I solve this?

slhck
  • 235,242
luckyo
  • 61

3 Answers3

8

You do not need sudo for Homebrew

Run:

brew install opencv

Homebrew never needs elevated privileges for anything – except for when there are some conflicts with other installed libraries:

Homebrew is designed to work without using sudo. You can decide to use it but we strongly recommend not to do so. If you have used sudo and run into a bug then it is likely to be the cause.

If you can't install it without sudo, make sure you own /usr/local and have the correct permissions – also by running this script. Running brew doctor will also generally give you some good hints.

slhck
  • 235,242
2

The install script of opencv wants to link the libraries into /usr/local/lib, but that directory needs higher privileges. Even if brew refuses to install as root, you can just use

sudo brew link opencv

after you ran sudo install as a user. This worked for me.

0

I have run into this same issue. A quick fix is to manually create the /usr/local/Cellar folder, then try again without sudo.