Public bug reported:

I had a problem installing a node package with npm

tim@spiff:~$ npm install jsdom
Traceback (most recent call last):
  File "/usr/bin/node-waf", line 6, in <module>
    if os.environ.has_key('PREFIX_NODE'):
AttributeError: '_Environ' object has no attribute 'has_key'
Traceback (most recent call last):
  File "/usr/bin/node-waf", line 6, in <module>
    if os.environ.has_key('PREFIX_NODE'):
AttributeError: '_Environ' object has no attribute 'has_key'
npm ERR! install failed Error: [email protected] preinstall: `node-waf clean || 
true; node-waf configure build`
...

It turns out that node-waf is a Python 2 script that ought to call
/usr/bin/python, but instead had a shebang line that searched the user's
environment for python. In my case, I had used pythonbrew to install
Python 3 locally

tim@spiff:~$ which python
/home/tim/.pythonbrew/pythons/Python-3.2.2/bin/python

This should have no effect on a system script in /usr/bin, but when a
script uses env that way, it has a profound effect. The fix is
simple...change the shebang line in /usr/bin/node-waf to call the
version of Python that it needs

sudo perl -pi.bak -e 's{#!/usr/bin/env python}{#!/usr/bin/python}'
/usr/bin/node-waf

This is the same issue as the one in
https://bugs.launchpad.net/ubuntu/+source/eyed3/+bug/307345

While /usr/bin/env is a wonderful thing and I often use it myself for
scripts in user space, it is really inappropriate for system scripts.
Perhaps it should be more difficult (impossible?) to create a package
that installs a script in /usr/bin with a shebang line that calls env
rather than the program that's actually required. I mean, why bother to
do all of that dependency checking if we're just going to fish around
for whatever version we can find each time the script is run?

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: nodejs-dev 0.4.9-1ubuntu3 [modified: usr/bin/node-waf]
ProcVersionSignature: Ubuntu 3.0.0-12.20-generic 3.0.4
Uname: Linux 3.0.0-12-generic x86_64
ApportVersion: 1.23-0ubuntu4
Architecture: amd64
Date: Sun Nov 20 07:26:31 2011
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: nodejs
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: nodejs (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug oneiric

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/892748

Title:
  node-waf uses env python rather than /usr/bin/python

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nodejs/+bug/892748/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to