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

nan 2.0.0 fails to build against node 0.10.x #394

Closed
rmoetwil opened this issue Aug 4, 2015 · 10 comments
Closed

nan 2.0.0 fails to build against node 0.10.x #394

rmoetwil opened this issue Aug 4, 2015 · 10 comments

Comments

@rmoetwil
Copy link

rmoetwil commented Aug 4, 2015

nan 2.0.0 fails to build against node 0.10.x

Reason for this is the usage of v8::String::REPLACE_INVALID_UTF8 in nan.h.
REPLACE_INVALID_UTF8 is not supported in node 0.10

E.g. when building sleep 3.0.0

> sleep@3.0.0 install ...node_modules/sleep
> node-gyp rebuild

make: Entering directory `...node_modules/sleep/build'
  CXX(target) Release/obj.target/node_sleep/sleep.o
In file included from ../sleep.cc:2:0:
../node_modules/nan/nan.h: In constructor ‘Nan::Utf8String::Utf8String(v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:1178:27: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
                           v8::String::REPLACE_INVALID_UTF8;

Apart from upgrading to node 0.12.x any ideas on how to resolve this?

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 4, 2015

Use a supported version of Node 0.10 then. The current one is at 0.10.40. REPLACE_INVALID_UTF8 is available since 0.10.29.

@kkoopa kkoopa closed this as completed Aug 4, 2015
@rmoetwil
Copy link
Author

rmoetwil commented Aug 4, 2015

Ok. I was misled by the documentation, see https://v8docs.nodesource.com/node-0.10/d2/db3/classv8_1_1_string.html, which doesn't show the option.

But indeed I see the REPLACE_INVALID_UTF8 patch was applied in 0.10.29 and onwards.

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 4, 2015

bnoordhuis added a commit that referenced this issue Aug 5, 2015
`v8::String::REPLACE_INVALID_UTF8` was added in node.js v0.10.29.
Check the version macros to see if it's available.

Fixes: #394
Fixes: #396
@kkoopa
Copy link
Collaborator

kkoopa commented Aug 10, 2015

As a followup: This should no longer be a problem.

@fivdi
Copy link

fivdi commented Aug 28, 2015

There appear to be constellations where this is still an issue, for example, with g++ 4.6.3 (yes, this is old) and node v0.10.29. Is this to be expected?

root@beaglebone:~/dev# g++ --version
g++ (Debian 4.6.3-14) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@beaglebone:~/dev# node -v
v0.10.29
root@beaglebone:~/dev# npm install epoll
|
> epoll@0.1.15 install /root/dev/node_modules/epoll
> node-gyp rebuild

make: Entering directory `/root/dev/node_modules/epoll/build'
  CXX(target) Release/obj.target/epoll/src/epoll.o
In file included from ../src/epoll.cc:15:0:
../node_modules/nan/nan.h:316:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
cc1plus: warning: unrecognized command line option "-Wno-unused-local-typedefs" [enabled by default]
make: *** [Release/obj.target/epoll/src/epoll.o] Error 1
make: Leaving directory `/root/dev/node_modules/epoll/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 3.8.13-bone70
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /root/dev/node_modules/epoll
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! epoll@0.1.15 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the epoll@0.1.15 install script.
npm ERR! This is most likely a problem with the epoll package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls epoll
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.8.13-bone70
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "epoll"
npm ERR! cwd /root/dev
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/dev/npm-debug.log
npm ERR! not ok code 0

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 28, 2015

No, you cannot have 0.10.29, since it should have `REPLACE_INVALID_UTF8". Build from source against the bundled V8 and try again.

@bnoordhuis
Copy link
Member

It can happen if you have a node binary from your distro vendor that doesn't carry the REPLACE_INVALID_UTF8 patch, e.g. because it's linked against a shared libv8. In that case you're pretty much out of luck, you're going to have to use an official binary.

@fivdi
Copy link

fivdi commented Aug 28, 2015

Yes, that's it. The node binary is from the distro vendor and doesn't carry the REPLACE_INVALID_UTF8 patch. v8.h has the following:

  enum WriteOptions {
    NO_OPTIONS = 0,
    HINT_MANY_WRITES_EXPECTED = 1,
    NO_NULL_TERMINATION = 2,
    PRESERVE_ASCII_NULL = 4
  };

rather that this:

  enum WriteOptions {
    NO_OPTIONS = 0,
    HINT_MANY_WRITES_EXPECTED = 1,
    NO_NULL_TERMINATION = 2,
    PRESERVE_ONE_BYTE_NULL = 4,
    // Used by WriteUtf8 to replace orphan surrogate code units with the
    // unicode replacement character. Needs to be set to guarantee valid UTF-8
    // output.
    REPLACE_INVALID_UTF8 = 8
  };

Thank you very much for the information.

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 28, 2015

@fivdi
Copy link

fivdi commented Aug 28, 2015

Excellent suggestion 👍

I just installed v0.10.40 from NodeSource and everything is working as expected. Thanks again.

root@beaglebone:~# g++ --version
g++ (Debian 4.6.3-14) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


root@beaglebone:~# node -v
v0.10.40


root@beaglebone:~# npm install epoll
\
> epoll@0.1.15 install /root/node_modules/epoll
> node-gyp rebuild

make: Entering directory `/root/node_modules/epoll/build'
  CXX(target) Release/obj.target/epoll/src/epoll.o
  SOLINK_MODULE(target) Release/obj.target/epoll.node
  SOLINK_MODULE(target) Release/obj.target/epoll.node: Finished
  COPY Release/epoll.node
make: Leaving directory `/root/node_modules/epoll/build'
epoll@0.1.15 node_modules/epoll
├── bindings@1.2.1
└── nan@2.0.8
root@beaglebone:~# 

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

No branches or pull requests

4 participants