mscdex / mmmagic

An async libmagic binding for node.js for detecting content types by data inspection
MIT License
620 stars 50 forks source link

Fails to build on Debian 8 #53

Closed soren121 closed 9 years ago

soren121 commented 9 years ago

Debian chose to rename the node.js binary to "nodejs" instead of "node" to avoid conflicts with other upstream packages that use the same binary name. As a result of PR #34, which calls node to check for NAN, npm fails to compile because it can't find the binary.

Is it possible to change the install script to avoid calling node? It seems a bit odd that mmmagic fails to compile on the most popular server distro.

NPM log attached.

\
> mmmagic@0.3.14 install /REDACTED/node_modules/mmmagic
> node-gyp rebuild

/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:344:16)
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.16.0-4-amd64
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /REDACTED/node_modules/mmmagic
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! mmmagic@0.3.14 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mmmagic@0.3.14 install script.
npm ERR! This is most likely a problem with the mmmagic 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 mmmagic
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.16.0-4-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /REDACTED
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!     /REDACTED/npm-debug.log
npm ERR! not ok code 0
mscdex commented 9 years ago

First of all, every addon on npm that I know of that uses nan uses this exact same format (node -e "require('nan')"), so it's not as if this is something unique to mmmagic.

Secondly, what do you propose that would not break for other distros?

Lastly, you can always sudo apt-get install nodejs-legacy to get the node symlink on Debian-based distros. However, typically you are better off getting your copy of node from some other source (repo, compiling manually, using pre-built tarballs, or otherwise) because the versions of node in official distro repositories more often than not get quickly outdated. This will especially be the case when releases from the converged node.js/io.js github repo start happening (although there will be LTS releases).

soren121 commented 9 years ago

I'm not very familiar with Node.js, so I figured I'd ask if it's something that can be fixed. I was installing NodeBB and this was the only package that failed installation; I thought maybe there was an alternative solution that other packages had switched to.

I'm not sure what the Debian Technical Committee thinks Node developers should do about this, apart from recommending nodejs-legacy, like you said. It seems like an inconsiderate decision on their part. I went ahead and symlinked nodejs to node on my system as there didn't seem to be any conflict.