mapbox / node-or-tools

Node.js bindings for or-tools vehicle routing problems
MIT License
146 stars 48 forks source link

Compatibility with Node 10.+ #54

Closed ntelkedzhiev closed 5 years ago

ntelkedzhiev commented 6 years ago

Had to downgrade to Node.js 9.7.1 to make it work...

daniel-j-h commented 6 years ago

What errors did you see? Can you provide more details?

We currently provide pre-built packages on npm for Node 4, 6, 8. If you want to add support for Node 10 you can modify the .travis.yaml file and open a pull request. Happy to review and merge it.

ntelkedzhiev commented 6 years ago

Will do. Thanks 👍

nnnikolay commented 6 years ago

Hey, @daniel-j-h I'm not sure if this connected with node 10 (in my case 10.3.0) or not, but can't install the module, am I doing something wrong?

$ npm i node_or_tools --save

> node_or_tools@1.0.5 install /Users/n/Projects/sandbox/ren/node_modules/node_or_tools
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/node_or_tools/v1.0.5/Release/node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for node_or_tools@1.0.5 and node@10.3.0 (node-v64 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://mapbox-node-binary.s3.amazonaws.com/node_or_tools/v1.0.5/Release/node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for node_or_tools@1.0.5 and node@10.3.0 (node-v64 ABI) (falling back to source compile with node-gyp)
  ACTION binding_gyp_action_before_build_target_install_deps mason_packages
  ACTION binding_gyp_action_before_build_target_install_deps mason_packages
Downloading Mason @ca9b4cb
Downloading Mason @ca9b4cb
* Downloading binary package osx-x86_64/protobuf/3.0.0.tar.gz...
fatal: Unable to read current working directory: No such file or directory
make: *** [mason_packages] Error 128
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/10.3.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding/node_or_tools.node" "--module_name=node_or_tools" "--module_path=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding"
gyp ERR! cwd /Users/n/Projects/sandbox/ren/node_modules/node_or_tools
gyp ERR! node -v v10.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
* Installed binary package at /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/protobuf/3.0.0
* Linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/protobuf/3.0.0
* Links will be inside /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/.link/
* Using bash fallback for symlinking (install lndir for faster symlinking)
* Done linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/protobuf/3.0.0
* Downloading binary package headers/sparsehash/2.0.2.tar.gz...
* Installed binary package at /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/headers/sparsehash/2.0.2
* Linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/headers/sparsehash/2.0.2
* Links will be inside /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/.link/
* Using bash fallback for symlinking (install lndir for faster symlinking)
* Done linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/headers/sparsehash/2.0.2
* Downloading binary package osx-x86_64/gflags/2.1.2.tar.gz...
* Installed binary package at /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/gflags/2.1.2
* Linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/gflags/2.1.2
* Links will be inside /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/.link/
* Using bash fallback for symlinking (install lndir for faster symlinking)
* Done linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/gflags/2.1.2
* Downloading binary package osx-x86_64/or-tools/6.0.tar.gz...
* Installed binary package at /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/or-tools/6.0
* Linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/or-tools/6.0
* Links will be inside /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/.link/
* Using bash fallback for symlinking (install lndir for faster symlinking)
* Done linking /Users/n/Projects/sandbox/ren/node_modules/node_or_tools/mason_packages/osx-x86_64/or-tools/6.0
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: unrecognized option: --strip-unneeded
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip [-AnuSXx] [-] [-d filename] [-s filename] [-R filename] [-o output] file [...]
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: unrecognized option: --strip-unneeded
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip [-AnuSXx] [-] [-d filename] [-s filename] [-R filename] [-o output] file [...]
  TOUCH Release/obj.target/action_before_build.stamp
  CXX(target) Release/obj.target/node_or_tools/src/main.o
In file included from ../src/main.cc:1:
In file included from ../src/tsp.h:6:
../src/adaptors.h:39:28: warning: 'Call' is deprecated [-Wdeprecated-declarations]
      auto cost = callback.Call(argc, argv);
                           ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
In file included from ../src/main.cc:1:
In file included from ../src/tsp.h:6:
../src/adaptors.h:64:30: warning: 'Call' is deprecated [-Wdeprecated-declarations]
    auto interval = callback.Call(argc, argv);
                             ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
In file included from ../src/main.cc:1:
In file included from ../src/tsp.h:6:
../src/adaptors.h:102:27: warning: 'Call' is deprecated [-Wdeprecated-declarations]
    auto locks = callback.Call(argc, argv);
                          ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
3 warnings generated.
  CXX(target) Release/obj.target/node_or_tools/src/tsp.o
In file included from ../src/tsp.cc:1:
In file included from ../src/tsp.h:6:
../src/adaptors.h:39:28: warning: 'Call' is deprecated [-Wdeprecated-declarations]
      auto cost = callback.Call(argc, argv);
                           ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
In file included from ../src/tsp.cc:1:
In file included from ../src/tsp.h:6:
../src/adaptors.h:64:30: warning: 'Call' is deprecated [-Wdeprecated-declarations]
    auto interval = callback.Call(argc, argv);
                             ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
In file included from ../src/tsp.cc:1:
In file included from ../src/tsp.h:6:
../src/adaptors.h:102:27: warning: 'Call' is deprecated [-Wdeprecated-declarations]
    auto locks = callback.Call(argc, argv);
                          ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
In file included from ../src/tsp.cc:3:
../src/tsp_worker.h:52:15: warning: 'Call' is deprecated [-Wdeprecated-declarations]
    callback->Call(argc, argv);
              ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/tsp.cc:31:37: error: no matching member function for call to 'NewInstance'
    info.GetReturnValue().Set(init->NewInstance());
                              ~~~~~~^~~~~~~~~~~
/Users/n/.node-gyp/10.3.0/include/node/v8.h:3862:44: note: candidate function not viable: requires single argument 'context', but no arguments were provided
  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                           ^
/Users/n/.node-gyp/10.3.0/include/node/v8.h:3859:44: note: candidate function not viable: requires 3 arguments, but 0 were provided
  V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                           ^
4 warnings and 1 error generated.
make: *** [Release/obj.target/node_or_tools/src/tsp.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/10.3.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding/node_or_tools.node" "--module_name=node_or_tools" "--module_path=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding"
gyp ERR! cwd /Users/n/Projects/sandbox/ren/node_modules/node_or_tools
gyp ERR! node -v v10.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/10.3.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding/node_or_tools.node --module_name=node_or_tools --module_path=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:961:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
node-pre-gyp ERR! System Darwin 17.5.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/10.3.0/bin/node" "/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/n/Projects/sandbox/ren/node_modules/node_or_tools
node-pre-gyp ERR! node -v v10.3.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node/10.3.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding/node_or_tools.node --module_name=node_or_tools --module_path=/Users/n/Projects/sandbox/ren/node_modules/node_or_tools/lib/binding' (1)
npm WARN ren@1.0.0 No description
npm WARN ren@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node_or_tools@1.0.5 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node_or_tools@1.0.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/n/.npm/_logs/2018-06-08T08_41_17_282Z-debug.log

Don't I have any -dev package system-wide?

daniel-j-h commented 6 years ago

Seems like this is a breaking change in the v8 API

../src/tsp.cc:31:37: error: no matching member function for call to 'NewInstance'
    info.GetReturnValue().Set(init->NewInstance());
                              ~~~~~~^~~~~~~~~~~

coming from

You can simply remove the branches for now and re-compile.

nnnikolay commented 6 years ago

@daniel-j-h sorry Daniel, what branches are you talking about?

daniel-j-h commented 6 years ago

In tsp.cc and vrp.cc remove

https://github.com/mapbox/node-or-tools/blob/30351e1ec9de80d779e570ca3313c2bcc1923a23/src/tsp.cc#L28-L33

and

https://github.com/mapbox/node-or-tools/blob/30351e1ec9de80d779e570ca3313c2bcc1923a23/src/vrp.cc#L27-L32

The NewInstance function calls seem to be not compatible with newer v8 versions.

ivosabev commented 5 years ago

Is this fix going to be release officially?

daniel-j-h commented 5 years ago

Happy to review a pull request if you want to help out here. It's not as easy as removing the two branches above as it will break compatibility with user code. But otherwise there should be nothing blocking this.

ivosabev commented 5 years ago

I have submitted a PR that I believe should fix the issue and preserve compatibility.

https://github.com/mapbox/node-or-tools/pull/57

daniel-j-h commented 5 years ago

Thanks! I merged your pull request, released v1.0.6. Travis automatically built binaries for LTS Node 4,6,8.

danpaz commented 5 years ago

@ivosabev have you been able to produce a build for node 10? I've been running into issues building in #62 although not much has changed since your PR #57.

ivosabev commented 5 years ago

@danpaz I was able to build it, but only in a fresh directory without any other dependencies in the package.json. If I try to build it from my project folder it calls twice mason and runs two concurrent builds resulting in a failure. I've described it in https://github.com/mapbox/node-or-tools/issues/59