chrisa / node-dtrace-provider

Native DTrace probes for node.js apps
Other
319 stars 70 forks source link

npm install shows errors (due to python 3 presence?) #123

Closed bburhans closed 5 years ago

bburhans commented 5 years ago

I'm using Windows 7 x64, running npm in a mingw64 mintty bash shell via Git Bash from Git for Windows.

This line is syntactically invalid in python 3:

import sys; print "%s.%s.%s" % sys.version_info[:3];

Result:

Traceback (most recent call last):
  File "python", line 1
    import sys; print "%s.%s.%s" % sys.version_info[:3];
                               ^
SyntaxError: invalid syntax

It would be valid under python 2, printing a version number.

This breaks the node-gyp rebuild when installing dtrace-provider:


$ npm i dtrace-provider --dev
npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.

> dtrace-provider@0.8.7 install J:\Documents\git\project\node_modules\dtrace-provider
> node-gyp rebuild || node suppress-error.js

J:\Documents\git\project\node_modules\dtrace-provider>if not defined npm_config_node_gyp (node "C:\Users\me\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\me\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\me\AppData\Local\Programs\Python\Python36-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:282:12)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:957:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:378:11)
gyp ERR! stack     at Socket.emit (events.js:182:13)
gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:598:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd J:\Documents\git\project\node_modules\dtrace-provider
gyp ERR! node -v v10.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
+ dtrace-provider@0.8.7
updated 1 package and audited 575 packages in 13.184s
found 0 vulnerabilities

In my case, dtrace-provider is a dependency of bunyan, and bunyan is a dependency of many other things; the npm install appears to succeed alone and as a dependency.

If it's not important that the rebuild succeed, I suppose should consider a more graceful way of detecting python 3 without executing a statement that simply can't be parsed in python 3, or generally failing more silently under python 2 or the lack thereof.

bburhans commented 5 years ago

My apologies, I just found the rest of the README about this specific issue and its resolution. I originally saw the section about failing to build on windows being fine due to a stub, and missed the bit about python2 in particular.