fix: print actionable hints when gyp fails on Android with missing NDK - #3356
Open
lesliechowsh wants to merge 1 commit into
Open
fix: print actionable hints when gyp fails on Android with missing NDK#3356lesliechowsh wants to merge 1 commit into
lesliechowsh wants to merge 1 commit into
Conversation
lesliechowsh
force-pushed
the
fix/android-actionable-gyp-error
branch
3 times, most recently
from
August 14, 2026 02:14
410ecac to
75603ec
Compare
|
Thank you for finding I did not know how to fix this problem in Nodejs before, because the error message was frustrating and did not previously explain that |
robertkirkman
approved these changes
Aug 14, 2026
When gyp fails with an undefined variable, only print the NDK/toolchain hint when the variable comes from the header toolchain itself (android_ndk_* names, or any undefined variable while loading common.gypi). A binding.gyp referencing its own undefined variable is a project bug; hinting about the NDK there would send the user down the wrong path. stderr remains forwarded byte-for-byte. The match logic lives in lib/configure.js, where gyp is spawned (configure()); it is exported as isNdkUndefinedVariableHint and covered by six unit cases (hit: android_ndk_path, android_ndk_* variant, common.gypi context; miss: project variable, unrelated error, empty).
lesliechowsh
force-pushed
the
fix/android-actionable-gyp-error
branch
from
August 14, 2026 13:07
75603ec to
4228eb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3355
When a native module build fails on Android (e.g. Termux) with "gyp: Undefined variable android_ndk_path in binding.gyp", the message looks like an internal gyp bug and nothing tells the user what to do. The variable comes from the android branch of the official Node headers'
common.gypi(downloaded vialib/process-release.js); it is only defined when Node itself is built with an NDK.This PR captures gyp's stderr in
lib/configure.jswhere gyp is spawned (still written through to the terminal byte-for-byte) and, when the failure matches anandroid_ndk_*variable or happens while loadingcommon.gypi(seeisNdkUndefinedVariableHint), prints actionable hints: use an NDK, or point node-gyp at system-toolchain headers via--nodedir/ a Node build with--use-prefix-to-find-headers(termux/termux-packages#30974).A binding.gyp referencing its own undefined variable is a project bug and does not trigger the hint, so users are not sent down the wrong path. Only the Android failure path is affected.