Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

You do not need sudo for Homebrew

As OpenCV now exists in homebrew/science, run the following:

brew tap homebrew/science
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.

share|improve this answer
    
If I do that I get: Cannot write to /usr/local/Cellar –  luckyo Feb 17 '12 at 13:21
2  
Did you ever mess around with chmod, possibly in combination with sudo there? Try sudo chown -R $USER /usr/local. Does it work after that? If not, please post a complete ls -la listing of /usr/local and what brew doctor says. –  slhck Feb 17 '12 at 13:23
1  
Warning: It appears you have MacPorts or Fink installed. Software installed with other package managers causes known problems for Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again. Error: Unsatisfied external dependency: numpy Homebrew does not provide Python dependencies, easy_install does: easy_install numpy –  luckyo Feb 17 '12 at 13:26
1  
Ahah, see, we're getting there. For the future, please include things like these in your question, we can't magically guess anything. I don't understand your latest question … please edit your original post and include the ls -la of /usr/local. Also, maybe think about uninstalling MacPorts or Fink, whatever you have. –  slhck Feb 17 '12 at 13:28
1  
That's probably not enough info. The group should probably be staff. But … this is the third time I've asked: Please post the complete output of ls -la /usr/local in your original question. – I'm glad to help, but you need to help a bit as well! –  slhck Feb 17 '12 at 13:42

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.

share|improve this answer
    
as another answer says, you should note that: "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." –  meduz Feb 3 at 8:41

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.