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
  • 223,558
  • 70
  • 607
  • 592
luckyo
  • 61
  • 1
  • 3

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
  • 223,558
  • 70
  • 607
  • 592
  • 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
  • Sorry it didnt work. But to what did you change the user. numpy is installed but i have to run python in 32 bit mode, cause I got 64 bit python installed. – luckyo Feb 17 '12 at 13:27
  • 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](http://superuser.com/posts/391021/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
  • Cellar has the following rights: drwxr-xr-x and wheel is the group. Is that enough info ? What else do you need. Thanks by the way for the help. – luckyo Feb 17 '12 at 13:32
  • 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
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.

  • 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 03 '14 at 08:41
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.