Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build 3.0.0 from source with Node 18 / node-gyp #374

Closed
A-Posthuman opened this issue Nov 19, 2022 · 4 comments
Closed

Can't build 3.0.0 from source with Node 18 / node-gyp #374

A-Posthuman opened this issue Nov 19, 2022 · 4 comments
Assignees

Comments

@A-Posthuman
Copy link

OS: Ubuntu 20.04

I see in your documentation it states python2.7 is required for install, but I can't seem to get the latest node-gyp to use it?

I do have it installed as /usr/bin/python2.7, and have tried to force node-gyp to use it via:

export PYTHON=/usr/bin/python2.7

creating a .npmrc file with python = "/usr/bin/python2.7"

export npm_config_python=/usr/bin/python2.7

Despite all these attempts, I still see in the failed build log:

gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"

which leads to the error:

614 error gyp info using node-gyp@9.3.0
614 error gyp info using node@18.12.1 | linux | x64
614 error gyp info spawn make
614 error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
614 error In file included from ../../nan/nan.h:60,
614 error from ../src/Curl.h:13,
614 error from ../src/node_libcurl.cc:7:
614 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:976:43: warning: cast between incompatible function types from ‘void ()(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void ()(v8::Localv8::Object)’} to ‘node::addon_register_func’ {aka ‘void ()(v8::Localv8::Object, v8::Localv8::Value, void)’} [-Wcast-function-type]
614 error 976 | (node::addon_register_func) (regfunc),
614 error | ^
614 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:1010:3: note: in expansion of macro ‘NODE_MODULE_X’
614 error 1010 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
614 error | ^~~~~~~~~~~~~
614 error ../src/node_libcurl.cc:68:1: note: in expansion of macro ‘NODE_MODULE’
614 error 68 | NODE_MODULE(node_libcurl, Init);
614 error | ^~~~~~~~~~~
614 error g++: fatal error: Killed signal terminated program cc1plus
614 error compilation terminated.
614 error make: *** [node_libcurl.target.mk:127: Release/obj.target/node_libcurl/src/Easy.o] Error 1
614 error gyp ERR! build error
614 error gyp ERR! stack Error: make failed with exit code: 2
614 error gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
614 error gyp ERR! stack at ChildProcess.emit (node:events:513:28)
614 error gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)

Is the problem with using python3.8? Or is there another issue? Thanks

@JCMais
Copy link
Owner

JCMais commented Nov 19, 2022

Python 3.0 is required, node-gyp will automatically try to find it, as it shows on your logs.

Could you send me a Dockerfile that reproduces the issue?

@A-Posthuman
Copy link
Author

I did some googling and found this electron issue:

[Bug]: Native modules that include nan.h fail to build on electron 20
electron/electron#35193

Is that the possible issue? I tried compiling the older node-libcurl 2.3.4 and also ended up with errors related to nan.h:

785 error In file included from ../src/Curl.h:13,
785 error from ../src/node_libcurl.cc:7:
785 error ../../nan/nan.h: In function ‘void Nan::SetAccessor(v8::Localv8::ObjectTemplate, v8::Localv8::String, Nan::GetterCallback, Nan::SetterCallback, v8::Localv8::Value, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’:
785 error ../../nan/nan.h:2551:16: warning: ‘void v8::ObjectTemplate::SetAccessor(v8::Localv8::Name, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Localv8::Value, v8::AccessControl, v8::PropertyAttribute, v8::Localv8::AccessorSignature, v8::SideEffectType, v8::SideEffectType)’ is deprecated: Do signature check in accessor [-Wdeprecated-declarations]
785 error 2551 | , signature);
785 error | ^
785 error In file included from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-function.h:15,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8.h:33,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:73,
785 error from ../../nan/nan.h:58,
785 error from ../src/Curl.h:13,
785 error from ../src/node_libcurl.cc:7:
785 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-template.h:838:8: note: declared here
785 error 838 | void SetAccessor(
785 error | ^~~~~~~~~~~
785 error In file included from ../../nan/nan.h:58,
785 error from ../src/Curl.h:13,
785 error from ../src/node_libcurl.cc:7:
785 error ../src/node_libcurl.cc: At global scope:
785 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:976:43: warning: cast between incompatible function types from ‘void ()(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void ()(v8::Localv8::Object)’} to ‘node::addon_register_func’ {aka ‘void ()(v8::Localv8::Object, v8::Localv8::Value, void)’} [-Wcast-function-type]
785 error 976 | (node::addon_register_func) (regfunc),
785 error | ^
785 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:1010:3: note: in expansion of macro ‘NODE_MODULE_X’
785 error 1010 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
785 error | ^~~~~~~~~~~~~
785 error ../src/node_libcurl.cc:68:1: note: in expansion of macro ‘NODE_MODULE’
785 error 68 | NODE_MODULE(node_libcurl, Init);
785 error | ^~~~~~~~~~~
785 error In file included from ../src/Curl.h:13,
785 error from ../src/Multi.h:10,
785 error from ../src/Easy.h:10,
785 error from ../src/Easy.cc:7:
785 error ../../nan/nan.h: In function ‘void Nan::SetAccessor(v8::Localv8::ObjectTemplate, v8::Localv8::String, Nan::GetterCallback, Nan::SetterCallback, v8::Localv8::Value, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’:
785 error ../../nan/nan.h:2551:16: warning: ‘void v8::ObjectTemplate::SetAccessor(v8::Localv8::Name, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Localv8::Value, v8::AccessControl, v8::PropertyAttribute, v8::Localv8::AccessorSignature, v8::SideEffectType, v8::SideEffectType)’ is deprecated: Do signature check in accessor [-Wdeprecated-declarations]
785 error 2551 | , signature);
785 error | ^
785 error In file included from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-function.h:15,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8.h:33,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:73,
785 error from ../../nan/nan.h:58,
785 error from ../src/Curl.h:13,
785 error from ../src/Multi.h:10,
785 error from ../src/Easy.h:10,
785 error from ../src/Easy.cc:7:
785 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-template.h:838:8: note: declared here
785 error 838 | void SetAccessor(
785 error | ^~~~~~~~~~~
785 error ../src/Easy.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE NodeLibcurl::Easy::GetInfo(Nan::NAN_METHOD_ARGS_TYPE)’:
785 error ../src/Easy.cc:2103:58: warning: ‘v8::Localv8::Context v8::Object::CreationContext()’ is deprecated: Use MaybeLocal GetCreationContext() [-Wdeprecated-declarations]
785 error 2103 | auto value = arr->Set(arr->CreationContext(), arr->Length(),
785 error | ^
785 error In file included from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-array-buffer.h:13,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8.h:24,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:73,
785 error from ../../nan/nan.h:58,
785 error from ../src/Curl.h:13,
785 error from ../src/Multi.h:10,
785 error from ../src/Easy.h:10,
785 error from ../src/Easy.cc:7:
785 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-object.h:598:18: note: declared here
785 error 598 | Local CreationContext();
785 error | ^~~~~~~~~~~~~~~
785 error ../src/Easy.cc:2137:56: warning: ‘v8::Localv8::Context v8::Object::CreationContext()’ is deprecated: Use MaybeLocal GetCreationContext() [-Wdeprecated-declarations]
785 error 2137 | auto value = arr->Set(arr->CreationContext(), arr->Length(),
785 error | ^
785 error In file included from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-array-buffer.h:13,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8.h:24,
785 error from /home/ubuntu/.cache/node-gyp/18.12.1/include/node/node.h:73,
785 error from ../../nan/nan.h:58,
785 error from ../src/Curl.h:13,
785 error from ../src/Multi.h:10,
785 error from ../src/Easy.h:10,
785 error from ../src/Easy.cc:7:
785 error /home/ubuntu/.cache/node-gyp/18.12.1/include/node/v8-object.h:598:18: note: declared here
785 error 598 | Local CreationContext();
785 error | ^~~~~~~~~~~~~~~
785 error g++: fatal error: Killed signal terminated program cc1plus
785 error compilation terminated.

Are you using any special config or settings or pinned versions of things not mentioned in your current documentation on how to build from source? I'm just using a fresh ubuntu 20.04 AWS instance, with the described prereqs installed and also installed curl-impersonate which I'm attempting to compile with.

@A-Posthuman
Copy link
Author

Hi, I figured out the issue, which was my bad: not enough ram and no swap on the instance I was using, leading to unpredictable issues when compiling things. After fixing that, the node-libcurl 3.0.0 compiled fine.

BTW, suggest to update/remove the reference to python 2.7 on the main readme file.

@JCMais
Copy link
Owner

JCMais commented Feb 13, 2024

references to python 2.7 were removed from the readme.

@JCMais JCMais closed this as completed Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants