The solution to node-gyp & Ruby FFI problems
After almost every update of MacOS, my Nodejs and Ruby set up seem to break. This has to do with the xcode command line utilities, as these are required when compiling a native extension like fsevents
using Apple’s clang compiler.
The errors look something like this:
xcode-select: error: tool 'xcodebuild' requires Xcode, butactive developer directory '/Library/Developer/CommandLineTools'is a command line tools instance
xcode-select: error: tool 'xcodebuild' requires Xcode, butactive developer directory '/Library/Developer/CommandLineTools'is a command line tools instance
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
Approach 1:
Have you tried turning it on and off?
(are they actually installed?)
xcode-select --install
This installs the command line tools.
Most of the time you will get xcode-select: error: command line tools are already installed, use "Software Update" to install updates
so you probably want to move on to the next approach.
Approach 2:
Clean reset
sudo xcode-select --reset
After running that in your terminal, restart it. If that doesn’t do it, you’ll need a more aggressive approach.
Approach 3:
Nuke it
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
You must then click your way through the licenses and prompts, and in about 10 minutes, the command line tools will have been reinstalled.
Note: It is not smart to copy and paste anything with rm -rf
in it, you should print the path first and delete it yourself.