50

I'd like to install openCV to vectorize image, but there's a series error message regarding Xcode and Ruby.

First, I use terminal to install openCV, brew install opencv.

Then, I got error message indicating that the system doesn't like my ruby version.

/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `<main>': 
Homebrew must be run under Ruby 2.3! You're running 2.0.0. (RuntimeError)

So, I want to upgrade my ruby. I followed several update strategy from this post. First ruby upgrade trial: brew link --overwrite ruby & brew unlink ruby && brew link ruby and get

Error: No such keg: /usr/local/Cellar/ruby

Then second ruby upgrade trial: brew upgrade ruby and see the following error message.

Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
xcode-select --install 

This error message means I need to install Xcode which I already install. So, I check my Xcode status with code-select -p and get /Applications/Xcode.app/Contents/Developer which means I am fine.

I saw a comment regarding where you install python could be a big issue. Quote from the source:

If you see /usr/local/bin/python3 then you are correctly using the Homebrew version of Python. If the output is instead /usr/bin/python3 then you are incorrectly using the system version of Python.

I check which python3 and get

/Users/******/anaconda3/bin/python3

Could this be the problem? How can I change system version to local?

Ying
  • 1,894
  • 1
  • 14
  • 20
  • 4
    The error says “please run this command to install command line tools since just having Xcode isn’t enough.” Did you run that command? – Sami Kuhmonen Nov 23 '17 at 16:44
  • 1
    Like @SamiKuhmonen mentioned, you need to actually have installed the command line tools. Even if you install (or any time you upgrade) Xcode you have to install the tools. There is a way to do it by opening Xcode and using the menus but the easiest is to just run the command the error mentions. – Beartech Nov 23 '17 at 19:32
  • 1
    Just a note: installing command line tools doesn't resolve this problem for me. I have command line tools installed, but still get the error "Error: Xcode alone is not sufficient on Sierra." (using homebrew python 2.7.14) – tsaulic Nov 24 '17 at 00:15
  • 1
    I met the same error, and the Xcode is also installed, but fixed this problem by run "xcode-select --install" and install the command line tool again. – patrick kuang Nov 24 '17 at 10:05
  • 3
    running `xcode-select --install` solved this problem for me. – Lion Lai Nov 24 '17 at 14:57

5 Answers5

64

Let me explain this myself so people won't make the same mistakes.

When I saw the last line of the error message

Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
xcode-select --install 

My thought was: I already have Xcode why the system ask me to "reinstall" it. However, thanks for @SamiKuhmonen @ Beartech @patrick kuang suggestion, I search a page (in Mandarin). xcode-select --install does not reinstall the whole Xcode. It means install some missing command line tools which is required by installing Ruby.

Ying
  • 1,894
  • 1
  • 14
  • 20
  • 2
    I don't know but I think something is wrong with Mac OS(10.14) distribution. Because, when I try to install X-Code command Line tools using the **command, it fails all the time**. I had to **manually download the Command Line Tools package from Apple Website as shown in the answer below.** I'm not saying this answer is wrong, but I felt sharing my experience. :) Hope this helps future answer seekers. – Abhishek Jan 29 '19 at 07:18
23

Trying to install k8s package via brew , I just got the same issue a while ago saying in the terminal :

Error: Xcode alone is not sufficient on Sierra.

Install the Command

Line Tools: xcode-select --install

You need to download *.dmg file; named Command Line Tools (macOS x.x.x) for XCode N . Search on it here : https://developer.apple.com/download/more/ . You must have developer account. enter image description here

Then, congrats!

update for 2019

macOS Mojave 10.14.5

Use Xcode10.2 for macOS 10.14

enter image description here

Community
  • 1
  • 1
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254
  • 1
    Screenshot is very helpful - have to use this if the command line xcode-select --install doesn't work – Hansang Jun 05 '19 at 02:44
13

I had the same issue in my Macbook Pro on Sierra. Apart from updating Xcode from the App Store, I also installed the command line utilities using the xcode-select --install command.

enter image description here

enter image description here

enter image description here

enter image description here

After the update steps, brew commands started working fine. I also updating my OS during this time.

Neel
  • 9,352
  • 23
  • 87
  • 128
7

I got the same message despite having Xcode and the command line tools already being installed a long time ago and updated numerous times.

I think it is the Apple way of telling you that Xcode command line tools need to be updated, as the App Store showed me the below:

Command Line Tools (mac OS Sierra version 10.12) for Xcode 9.1

After executing the xcode-select --install command, the update disappears from the App Store, which means they are exactly the same thing.

Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
  • Thanks for your comment! I checked my Xcode update status as well. From both terminal and in "App store", it seems that there is nothing I need to update. – Ying Nov 27 '17 at 16:40
  • 1
    @Ying that's the thing: installing the update from the App Store does the same as running the command `xcode-select --install`, which means that after running the command, you will not see the update in the App Store any more. – Jeroen Wiert Pluimers Nov 28 '17 at 17:47
  • @Jeron I didn't mention clearly in my question. I do check in the App Store and I didn't see anything I need to update there. That's why I am confused and didn't run `xcode-select --install`. However, `xcode-select --install` is the correct way to solve my issue. – Ying Nov 29 '17 at 20:20
  • @Ying you are right: the App Store sometimes forgets to refresh itself. I always do a manual refresh in it (with the `Command-R` key combination). – Jeroen Wiert Pluimers Nov 30 '17 at 08:08
0

I had the same problem. I installed 'Command Line Tools for XCode' (choose appropriate version) from https://developer.apple.com/download/more/ and restarted my terminal. Issue resolved :)

Jay
  • 21
  • 2