nodejs / gyp-next

A fork of the GYP build system for use in the Node.js projects
BSD 3-Clause "New" or "Revised" License
130 stars 73 forks source link

npm ERR! gyp: Undefined variable android_ndk_path in binding.gyp while trying to load binding.gyp #237

Closed Freed-Wu closed 6 months ago

Freed-Wu commented 6 months ago

npm rebuild in Android/termux meet this bug. However I cannot found android_ndk_path in gyp's code repo. How to solve it? TIA!

cclauss commented 6 months ago

Error log?

Freed-Wu commented 6 months ago

2024-03-27T16_39_28_462Z-debug-0.log

It looks like node-gyp add some gypi contains this variable:

$ rg android_ndk_path /data/data/com.termux/files/home/.cache/node-gyp/21.6.2/include/node/common.gypi
241:            'cflags': [ '-fPIC', '-I<(android_ndk_path)/sources/android/cpufeatures' ],
cclauss commented 6 months ago

It looks like the alpha software crashed. What happens when you remove that software from the build?

35 info run coc-rime@0.1.3-alpha install node-gyp rebuild 36 info run coc-rime@0.1.3-alpha install { code: 1, signal: null } 37 timing command:rebuild Completed in 1514ms 38 verbose stack Error: command failed 38 verbose stack at ChildProcess. (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27) 38 verbose stack at ChildProcess.emit (node:events:519:28) 38 verbose stack at maybeClose (node:internal/child_process:1105:16) 38 verbose stack at ChildProcess._handle.onexit (node:internal/child_process:305:5)

cclauss commented 6 months ago

Closing in favor of

Freed-Wu commented 6 months ago

After https://github.com/tonyfettes/coc-rime/commit/c91900b01ca84c1e43f53958dca30d3a59b23ab4, it can be build in Android/termux. So can we add a default android_ndk_path to avoid this bug?

PS: It should be added in node-gyp's js code?

cclauss commented 6 months ago

The error messages on tonyfettes/coc-rime#7 say nothing about android_ndk_path. Let’s get that merged so that we have clear evidence of a android_ndk_path problem so that we can recruit other to fix that problem.

Freed-Wu commented 6 months ago

It's my fault. Let me explain the full steps:

  1. Install https://github.com/termux/termux-app to an Android device
apt install nodejs librime json-c pkg-config
git clone --depth=1 https://github.com/tonyfettes/coc-rime
cd coc-rime
# before https://github.com/tonyfettes/coc-rime/commit/c91900b01ca84c1e43f53958dca30d3a59b23ab4
git checkout f307fa8c71a042663111705e14611444cacc2955
npm install
npm rebuild

You will set that error message.