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

Cannot rebuild zeromq due to module code incompatibilities #343

Closed
abulka opened this issue Dec 14, 2019 · 3 comments
Closed

Cannot rebuild zeromq due to module code incompatibilities #343

abulka opened this issue Dec 14, 2019 · 3 comments
Labels

Comments

@abulka
Copy link

abulka commented Dec 14, 2019

Creating a new electron-forge project and installing zerorpc via npm works. Attempting an electron-rebuild however fails, with a node-gyp error. There are over a dozen unresolved questions about this problem (or slight variants) on the internet.

  • ubuntu 18.04
  • node v12.13.1
  • npm 6.12.1
  • electron 7.1.5
  • electron-rebuild@1.8.8
  • electron-forge via npx electron-forge --version 6.0.0-beta.46

To reproduce:

  • sudo apt-get install libtool pkg-config build-essential autoconf automake git cmake
  • npx create-electron-app e1
  • cd e1
  • npm install electron-rebuild --save-dev
  • $(npm bin)/electron-rebuild
  • npm install zerorpc --save
  • $(npm bin)/electron-rebuild <---- fails
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/andy/Devel/e1a/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 5.0.0-37-generic
gyp ERR! command "/home/andy/.nvm/versions/node/v12.13.1/bin/node" "/home/andy/Devel/e1a/node_modules/.bin/node-gyp" "rebuild" "--target=7.1.5" "--arch=x64" "--dist-url=https://electronjs.org/headers" "--build-from-source"
gyp ERR! cwd /home/andy/Devel/e1a/node_modules/zeromq
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v6.0.1
gyp ERR! not ok 

Easy to reproduce, as you can see. The only solution I found was to switch to electron 3 by editing package.json and changing "electron": "7.1.5", to "electron": "3", then rm -rf node_modules, npm install. Now running $(npm bin)/electron-rebuild succeeds.

Wading through the attempted solutions out there, I found nothing worked. I tried:

  • Installing node-gyp globally with npm install -g node-gyp
  • Installing zeromq explicitly with npm install --save zeromq
  • Installing zeromq from source npm install zeromq --build-from-source --save
  • Installing libzmq3-dev with sudo apt-get install libzmq3-dev
  • Setting python2 for npm npm config set python /usr/bin/python2
  • Setting specifying python2 for node-gyp (wild guess) node-gyp rebuild --python /usr/bin/python2
  • Playing with mysterious abi stuff e.g. npm rebuild zeromq --runtime=electron --target=7.1.4 --abi=75 and npm rebuild zeromq --runtime=electron --target=12.8.1 --abi=75 since there seems to be some confusion re whether target refers to electron or node. Tried different abi numbers e.g. 72. Often getting error downloading headers.
  • Tried rebuilding zeromq without specifying params npm rebuild zeromq --runtime=electron
  • Tried cd into zeromq and rebuild usng command line as per this advice. cd node_modules/zeromq/ then HOME=~/.electron-gyp node-gyp rebuild --target=7.1.4 --arch=x64 --dist-url=https://electronjs.org/headers which actually compiles, but then running npm start triggers a rebuild and fails.
  • Read the promise by the zeromq guys that prebuilt binaries for zeromq incl. those for electron's needs are available, and wondered why these never happened for me - all I got were compiles from source.

So now I'm on Electron 3.1.13 and everything works, but would like to be able to run later versions of Electron.

@malept malept added the invalid label Dec 14, 2019
@malept
Copy link
Member

malept commented Dec 14, 2019

This doesn't work because of compile errors (which you didn't provide). This isn't the fault of electron-rebuild, but rather because of source code incompatibilities with the version of Node that's bundled with the latest stable version of Electron (Node 12 for Electron 7, for example). zerorpc 0.9.8 installs zeromq 4.6.0, which is from 2 years ago.

Here's an example of incompatibilities that happened with Electron 5 (although it doesn't seem like this is the problem here): https://electronjs.org/blog/nodejs-native-addons-and-electron-5

Compile errors
make: Entering directory '/tmp/zero/node_modules/zeromq/build'
  CXX(target) Release/obj.target/zmq/binding.o
In file included from $HOME/.electron-gyp/7.1.5/include/node/v8-internal.h:14,
                 from $HOME/.electron-gyp/7.1.5/include/node/v8.h:27,
                 from ../binding.cc:24:
$HOME/.electron-gyp/7.1.5/include/node/v8config.h:343:49: warning: ‘MicrotasksCompletedCallback’ is deprecated [-Wdeprecated-declarations]
   declarator __attribute__((deprecated(message)))
                                                 ^
$HOME/.electron-gyp/7.1.5/include/node/v8.h:8513:3: note: in expansion of macro ‘V8_DEPRECATE_SOON’
   V8_DEPRECATE_SOON("Use *WithData version.",
   ^~~~~~~~~~~~~~~~~
$HOME/.electron-gyp/7.1.5/include/node/v8config.h:343:49: warning: ‘MicrotasksCompletedCallback’ is deprecated [-Wdeprecated-declarations]
   declarator __attribute__((deprecated(message)))
                                                 ^
$HOME/.electron-gyp/7.1.5/include/node/v8.h:8522:3: note: in expansion of macro ‘V8_DEPRECATE_SOON’
   V8_DEPRECATE_SOON("Use *WithData version.",
   ^~~~~~~~~~~~~~~~~
In file included from ../binding.cc:40:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2298:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast(AsyncExecuteComplete)
                                                              ^
../binding.cc: In member function ‘void zmq::Socket::NotifyReadReady()’:
../binding.cc:394:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 0, NULL);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc:394:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 0, NULL);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc: In member function ‘void zmq::Socket::NotifySendReady()’:
../binding.cc:402:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 0, NULL);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc:402:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 0, NULL);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc: In member function ‘void zmq::Socket::MonitorEvent(uint16_t, int32_t, char*)’:
../binding.cc:453:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 4, argv);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc:453:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 4, argv);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc: In member function ‘void zmq::Socket::MonitorError(const char*)’:
../binding.cc:468:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 1, argv);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc:468:73: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(this->handle(), callback_v.As(), 1, argv);
                                                                         ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc: In static member function ‘static void zmq::Socket::UV_MonitorCallback(uv_timer_t*, int)’:
../binding.cc:540:98: warning: cast between incompatible function types from ‘void (*)(uv_timer_t*, int)’ {aka ‘void (*)(uv_timer_s*, int)’} to ‘uv_timer_cb’ {aka ‘void (*)(uv_timer_s*)’} [-Wcast-function-type]
       uv_timer_start(s->monitor_handle_, reinterpret_cast(Socket::UV_MonitorCallback), s->timer_interval_, 0);
                                                                                                  ^
../binding.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE zmq::Socket::Bind(Nan::NAN_METHOD_ARGS_TYPE)’:
../binding.cc:774:37: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
                   (uv_after_work_cb)UV_BindAsyncAfter);
                                     ^~~~~~~~~~~~~~~~~
../binding.cc: In static member function ‘static void zmq::Socket::UV_BindAsyncAfter(uv_work_t*)’:
../binding.cc:809:70: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, 1, argv);
                                                                      ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc:809:70: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, 1, argv);
                                                                      ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE zmq::Socket::Unbind(Nan::NAN_METHOD_ARGS_TYPE)’:
../binding.cc:855:37: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
                   (uv_after_work_cb)UV_UnbindAsyncAfter);
                                     ^~~~~~~~~~~~~~~~~~~
../binding.cc: In static member function ‘static void zmq::Socket::UV_UnbindAsyncAfter(uv_work_t*)’:
../binding.cc:888:70: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, 1, argv);
                                                                      ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc:888:70: warning: ‘v8::Local Nan::MakeCallback(v8::Local, v8::Local, int, v8::Local*)’ is deprecated [-Wdeprecated-declarations]
     Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, 1, argv);
                                                                      ^
In file included from ../binding.cc:40:
../../nan/nan.h:1024:46: note: declared here
   NAN_DEPRECATED inline v8::Local MakeCallback(
                                              ^~~~~~~~~~~~
../binding.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE zmq::Socket::Monitor(Nan::NAN_METHOD_ARGS_TYPE)’:
../binding.cc:1057:103: warning: cast between incompatible function types from ‘void (*)(uv_timer_t*, int)’ {aka ‘void (*)(uv_timer_s*, int)’} to ‘uv_timer_cb’ {aka ‘void (*)(uv_timer_s*)’} [-Wcast-function-type]
       uv_timer_start(socket->monitor_handle_, reinterpret_cast(Socket::UV_MonitorCallback), timer_interval, 0);
                                                                                                       ^
../binding.cc: In constructor ‘zmq::Socket::OutgoingMessage::BufferReference::BufferReference(v8::Local)’:
../binding.cc:1227:78: warning: cast between incompatible function types from ‘void (*)(uv_async_t*, int)’ {aka ‘void (*)(uv_async_s*, int)’} to ‘uv_async_cb’ {aka ‘void (*)(uv_async_s*)’} [-Wcast-function-type]
             uv_async_init(loop, &async, reinterpret_cast(cleanup));
                                                                              ^
../binding.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE zmq::Socket::Sendv(Nan::NAN_METHOD_ARGS_TYPE)’:
../binding.cc:1295:39: error: no matching function for call to ‘v8::Array::Get(uint32_t&)’
       Local buf = batch->Get(i).As();
                                       ^
In file included from ../binding.cc:24:
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3502:43: note: candidate: ‘v8::MaybeLocal v8::Object::Get(v8::Local, v8::Local)’
   V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context,
                                           ^~~
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3502:43: note:   candidate expects 2 arguments, 1 provided
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3505:43: note: candidate: ‘v8::MaybeLocal v8::Object::Get(v8::Local, uint32_t)’
   V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context,
                                           ^~~
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3505:43: note:   candidate expects 2 arguments, 1 provided
../binding.cc:1295:50: error: expected primary-expression before ‘>’ token
       Local buf = batch->Get(i).As();
                                                  ^
../binding.cc:1295:52: error: expected primary-expression before ‘)’ token
       Local buf = batch->Get(i).As();
                                                    ^
../binding.cc:1296:48: error: no matching function for call to ‘v8::Array::Get(uint32_t)’
       Local flagsObj = batch->Get(i + 1).As();
                                                ^
In file included from ../binding.cc:24:
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3502:43: note: candidate: ‘v8::MaybeLocal v8::Object::Get(v8::Local, v8::Local)’
   V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context,
                                           ^~~
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3502:43: note:   candidate expects 2 arguments, 1 provided
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3505:43: note: candidate: ‘v8::MaybeLocal v8::Object::Get(v8::Local, uint32_t)’
   V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context,
                                           ^~~
$HOME/.electron-gyp/7.1.5/include/node/v8.h:3505:43: note:   candidate expects 2 arguments, 1 provided
../binding.cc:1296:59: error: expected primary-expression before ‘>’ token
       Local flagsObj = batch->Get(i + 1).As();
                                                           ^
../binding.cc:1296:61: error: expected primary-expression before ‘)’ token
       Local flagsObj = batch->Get(i + 1).As();
                                                             ^
In file included from ../binding.cc:25:
../binding.cc: At global scope:
$HOME/.electron-gyp/7.1.5/include/node/node.h:572:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local, v8::Local, void*)’} [-Wcast-function-type]
       (node::addon_register_func) (regfunc),                          \
                                           ^
$HOME/.electron-gyp/7.1.5/include/node/node.h:606:3: note: in expansion of macro ‘NODE_MODULE_X’
   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
   ^~~~~~~~~~~~~
../binding.cc:1610:1: note: in expansion of macro ‘NODE_MODULE’
 NODE_MODULE(zmq, init)
 ^~~~~~~~~~~
In file included from ../binding.cc:24:
$HOME/.electron-gyp/7.1.5/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P*, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void (*)(const v8::WeakCallbackInfo&)]’: $HOME/.electron-gyp/7.1.5/include/node/node_object_wrap.h:84:78: required from here $HOME/.electron-gyp/7.1.5/include/node/v8.h:10141:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} [-Wcast-function-type] reinterpret_cast(callback), type); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $HOME/.electron-gyp/7.1.5/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P*, typename v8::WeakCallbackInfo

::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo

::Callback = void (*)(const v8::WeakCallbackInfo&)]’: ../../nan/nan_object_wrap.h:65:61: required from here $HOME/.electron-gyp/7.1.5/include/node/v8.h:10141:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} [-Wcast-function-type] make: *** [zmq.target.mk:109: Release/obj.target/zmq/binding.o] Error 1 make: Leaving directory '/tmp/zero/node_modules/zeromq/build'

@malept malept closed this as completed Dec 14, 2019
@malept malept changed the title Cannot rebuild zeromq in electron-forge projects Cannot rebuild zeromq due to module code incompatibilities Dec 14, 2019
@abulka
Copy link
Author

abulka commented Dec 14, 2019

@malept After two days researching this and documenting my results (above), can you please recommend where I and dozens of others can find a remedy to this? If its not electron-rebuild - is there a particular project where an issue can be raised?

@malept
Copy link
Member

malept commented Dec 14, 2019

Seems like you need to use a version of zerorpc that works with zeromq version >= 5. I got 5.2.0 and the latest 6 beta versions of zeromq successfully rebuilt locally when I removed zerorpc, added zeromq, and ran npm start.

If you need more assistance, please use one of the community forums. The issue tracker is meant for bugs / feature requests in electron-rebuild itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants