MacOS – Broken Command Line Tools on Sierra, can’t install Node.js native packages, build Python etc

command linemacospythonxcode

I'm on macOS Sierra 10.12.1 (16B2555) with Xcode 8.1 & Command Line Tools installed but I can't install any Node.js native add-ons, I can't compile Python etc.

I've tried removing Xcode and Command Line Tools (the latter via removing /Library/Developer/CommandLineTools) and then reinstalled Xcode from App Store and Command Line Tools via xcode-select --install but the problem is still there. For example, this is what happens if I try to install the contextify npm package on Node.js 7.2.0 or 6.9.1:

$ npm install contextify

> contextify@0.1.15 install /Users/mgol/_/node_modules/contextify
> node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  CXX(target) Release/obj.target/contextify/src/contextify.o
make: ccache: No such file or directory
make: *** [Release/obj.target/contextify/src/contextify.o] Error 1
gyp ERR! build error 

It works fine on a colleague's machine with the same OS.

I sometimes see App Store notifying me of a Command Line Tools upgrade for Xcode 7.3 which seems off, maybe my setup has some leftover from the old Xcode?

Any ideas? I feel lost in what else I can try.

Best Answer

From your log, it looks like the build process expects ccache to be installed. Depending on your preference, use either Homebrew or MacPorts to install ccache, and then try the build again.