Bug 217984 - www/npm: cannot build native modules with node-gyp (python not found)
Summary: www/npm: cannot build native modules with node-gyp (python not found)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Sunpoet Po-Chuan Hsieh
Depends on:
Reported: 2017-03-21 20:23 UTC by Bradley T. Hughes
Modified: 2017-04-03 18:23 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (sunpoet)
bhughes: maintainer-feedback? (sunpoet)


Note You need to log in before you can comment on or make changes to this bug.
Description Bradley T. Hughes freebsd_committer 2017-03-21 20:23:02 UTC
I installed node and npm via pkg, then try to install a module that needs to compile a native module. This fails because the "python" command is not found. I can work around this by running `env PYTHON=python2.7 npm i $package`.

Example error:

$ npm i unix-dgram

> unix-dgram@2.0.0 install /usr/home/bhughes/someproject/node_modules/unix-dgram
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:454:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:368:16)
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:114:15)
gyp ERR! System FreeBSD 11.0-RELEASE-p8
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/home/bhughes/someproject/node_modules/unix-dgram
gyp ERR! node -v v7.7.3
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok 
npm WARN someproject No description
npm WARN someproject No repository field.
npm WARN someproject No license field.
npm ERR! FreeBSD 11.0-RELEASE-p8
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "unix-dgram"
npm ERR! node v7.7.3
npm ERR! npm  v4.3.0
npm ERR! errno 1

npm ERR! unix-dgram@2.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the unix-dgram@2.0.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the unix-dgram 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 information on how to open an issue for this project with:
npm ERR!     npm bugs unix-dgram
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls unix-dgram
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/bhughes/.npm/_logs/2017-03-21T20_19_11_780Z-debug.log
Comment 1 Sunpoet Po-Chuan Hsieh freebsd_committer 2017-03-25 03:04:16 UTC
Bradley, could you please check if it works with python2 installed?
Comment 2 Bradley T. Hughes freebsd_committer 2017-03-27 20:01:53 UTC
(In reply to Po-Chuan Hsieh from comment #1)

Yes, it does work after `pkg install python2`
Comment 3 commit-hook freebsd_committer 2017-03-31 20:40:17 UTC
A commit references this bug:

Author: sunpoet
Date: Fri Mar 31 20:38:56 UTC 2017
New revision: 437373
URL: https://svnweb.freebsd.org/changeset/ports/437373

  Use USES=python:2 instead of USES=python:2.7

  - Bump PORTREVISION for dependency change

  PR:		217984
  Reported by:	Bradley T. Hughes <bradleythughes@fastmail.fm>

Comment 4 Sunpoet Po-Chuan Hsieh freebsd_committer 2017-03-31 20:47:37 UTC
Committed. Thanks!
Comment 5 Bradley T. Hughes freebsd_committer 2017-04-03 18:23:24 UTC
Great, thanks! :)