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

Fix calling node/nodejs binary in nodejs_version #1

Merged
merged 1 commit into from Sep 17, 2016

Conversation

maikelwever
Copy link
Contributor

@maikelwever maikelwever commented Sep 16, 2016

The primary nodejs executable being called nodejs is a Debian-ism, and is not compatible with upstream nodejs and non-Debian distros, because upstream just calls the binary node.

This makes the node_version which calls nodejs --version method fail on non-Debian systems, where nodejs is actually called node instead.

Instead of just executing the nodejs command, we now first search for it in PATH, using distutils.spawn.find_executable, which should be available on Python 2.4+. (see also: http://stackoverflow.com/a/12611523)

When no node executable is found, a NodeBinaryNotFoundError is now raised.

If one of the node executables is found, we return the result of node/nodejs --version as before.

Edit: to clarify: the reasoning behind Debian not calling node node, is that /usr/bin/node is actually in use by a package that pre-exists nodejs (ax25-node). Since the search for nodejs is before the search for node, this should not give any problems for users that have both installed. There might be a false positive when ax25-node is installed, but nodejs is not, but I think we can assume here npm users have nodejs installed already anyway ;)

- The primary nodejs executable being called
  `nodejs` is a Debian-ism, and is not compatible
  with upstream nodejs and non-Debian distros,
  because upstream just calls the binary `node`.

- This makes the `node_version` method fail
  on non-Debian systems, where `nodejs` is
  actually called `node` instead.

- Instead of just executing the `nodejs` command,
  we now first search for it in `PATH`, using
  `distutils.spawn.find_executable`, which
  should be available on Python 2.4+.

- When no node executable is found,
  a NodeBinaryNotFoundError is now raised.

- If one of the node executables is found,
  we return the result of `node/nodejs --version`
  as before.
@coveralls
Copy link

coveralls commented Sep 16, 2016

Coverage Status

Coverage decreased (-1.04%) to 93.385% when pulling 0aa2404 on maikelwever:fixes/node-binary-name into 4edacdb on xolox:master.

@xolox xolox merged commit 0aa2404 into xolox:master Sep 17, 2016
@xolox
Copy link
Owner

xolox commented Sep 17, 2016

Hey Maikel and thanks for 1) reporting this issue and 2) providing a fix!

Obviously I know so little about Node.js that I never realized that the official name of the interpreter is simply node, sorry about that :-).

I changed things around quite a bit while merging your pull request but conceptually the same fix is now implemented. I just pushed the results to GitHub, if Travis CI doesn't complain I will publish this to PyPI as well.

@xolox
Copy link
Owner

xolox commented Sep 17, 2016

Travis CI agrees (including the new test I added) so this is now on PyPI!

@maikelwever
Copy link
Contributor Author

This means npm-accel now works on Arch Linux \o/

So I made an AUR package for it (and its dependencies): https://aur.archlinux.org/packages/npm-accel/

xolox added a commit that referenced this pull request Sep 17, 2016
Refer to pull request #1 for details:
#1 (comment)
@xolox
Copy link
Owner

xolox commented Sep 17, 2016

Thanks for that Maikel! I've added a mention of the AUR package in README.rst.

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

Successfully merging this pull request may close these issues.

None yet

3 participants