node-gyp: node-gyp fails on Sonoma with CLI only and not XCode (Mac M1 / Apple Silicon)
node-gyp fails on Sonoma with CLI only and not XCode (Mac M1 / Apple Silicon)
At https://github.com/nodejs/node-gyp/blob/main/gyp/pylib/gyp/xcode_emulation.py#L1496C41-L1496C51 it appears to be looking for version numbers at the end of the “xcodebuild -version” command. But for me, that command does not produce version numbers, see below
The code seems to describe itself working well even if the box only has CLI tools and not full Xcode, but that doesn’t seem to be the case in reality:
$ uname -a Darwin Geoffs-Mac-mini.local 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:06 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T8103 arm64 (base)
$ xcodebuild -version xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
Mac M1 / Sonoma 14.4
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (8 by maintainers)
FYI: I encountered the same problem and found a solution in node-gyp 9.x.
I don’t know why it works, but it resolved.
node-gyp: v9.4.1 OS: M1 MacOS Sonoma 14.4.1 Python: v3.12.1 Node: v20.11.1
Python 3.12 requires node-gyp >= v10.
Upgrade to node-gyp@10 or downgrade to python@3.11.
source
create a binding.gyp file and place it in your project root. the content of the file looks like this:
{ "targets": [ { "target_name": "binding", "sources": [ "src/binding.cc" ] } ] }@cclauss Thanks for the ideas! I will try the github action shortly. In the meantime, I tried your env var, did not alter the result much:
$ export NODE_GYP_FORCE_PYTHON=python3 $ echo $NODE_GYP_FORCE_PYTHON
python3 $ pnpm install