googleapis/cloud-profiler-nodejs

npm install fails on MacOS

Closed this issue · 15 comments

With the latest (11.10) nodejs, I am struggling to run npm install on master:

cloud-profiler-nodejs (master) $ npm install

> @google-cloud/profiler@1.0.1-alpha.0 install /Users/beckwith/Code/cloud-profiler-nodejs
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/cloud-profiler/nodejs/release/v1.0.1-alpha.0/node-v67-darwin-x64-unknown.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for @google-cloud/profiler@1.0.1-alpha.0 and node@11.10.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp) 
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/beckwith/.nvm/versions/node/v11.10.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/Users/beckwith/.nvm/versions/node/v11.10.0/bin/node" "/Users/beckwith/.nvm/versions/node/v11.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/beckwith/Code/cloud-profiler-nodejs/build/node-v67-darwin-x64-unknown/google_cloud_profiler.node" "--module_name=google_cloud_profiler" "--module_path=/Users/beckwith/Code/cloud-profiler-nodejs/build/node-v67-darwin-x64-unknown" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v67"
gyp ERR! cwd /Users/beckwith/Code/cloud-profiler-nodejs
gyp ERR! node -v v11.10.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/Users/beckwith/.nvm/versions/node/v11.10.0/bin/node /Users/beckwith/.nvm/versions/node/v11.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/beckwith/Code/cloud-profiler-nodejs/build/node-v67-darwin-x64-unknown/google_cloud_profiler.node --module_name=google_cloud_profiler --module_path=/Users/beckwith/Code/cloud-profiler-nodejs/build/node-v67-darwin-x64-unknown --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/beckwith/Code/cloud-profiler-nodejs/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:984:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/Users/beckwith/.nvm/versions/node/v11.10.0/bin/node" "/Users/beckwith/Code/cloud-profiler-nodejs/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/beckwith/Code/cloud-profiler-nodejs
node-pre-gyp ERR! node -v v11.10.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok 
Failed to execute '/Users/beckwith/.nvm/versions/node/v11.10.0/bin/node /Users/beckwith/.nvm/versions/node/v11.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/beckwith/Code/cloud-profiler-nodejs/build/node-v67-darwin-x64-unknown/google_cloud_profiler.node --module_name=google_cloud_profiler --module_path=/Users/beckwith/Code/cloud-profiler-nodejs/build/node-v67-darwin-x64-unknown --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google-cloud/profiler@1.0.1-alpha.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @google-cloud/profiler@1.0.1-alpha.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/beckwith/.npm/_logs/2019-02-15T00_20_40_814Z-debug.log
cloud-profiler-nodejs (master) $ 

Looking now.
I can't reproduce on my linux workstation... But it looks like JustinBeckwith is using a Mac. This is a node-gyp failure (so, the failure occurs when binaries are being compiled) -- that makes it more likely to be OS-specific.

We've also never run continuous tests on Mac.. so I don't know it the profiler has ever worked on Mac.

@JustinBeckwith -- Is this specific to Node 11.10, or does this also happen with older versions of Node?

This also happens with 10.15.1.

Looks like for node-gyp to work on MacOS, Xcode has to be installed:
https://github.com/nodejs/node-gyp#on-macos

This increases urgency for pre-compiled binaries for MacOS

Given the profiler is primarily for profiling production environments and those are rarely OSX I am marking it as p2 instead of p1.

The problem is that nobody on OSX can actually run npm install @google-cloud/profiler, so I can't develop my app if I use it. This is not good 😟

There is a work-around (installing Xcode).

Should we document that while working on pre-compiled binaries?

If this is only an issues on master (not the shipped module), and it'll get fixed with the next release - I say let it lie.

I'm closing this, because I now want to track this in pprof-nodejs (which has the native component now).

New issue here: google/pprof-nodejs#33

Any update on this? I'm still experiencing this error:

npm install @google-cloud/profiler

> pprof@0.2.0 install /..../node_modules/pprof
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/cloud-profiler/pprof-nodejs/release/v0.2.0/node-v64-darwin-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for pprof@0.2.0 and node@10.13.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/local/bin/python -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:289:12)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:381:11)
gyp ERR! stack     at Socket.emit (events.js:182:13)
gyp ERR! stack     at Pipe._handle.close (net.js:606:12)

@jhnferraris -- Do you have python 2 installed? Is it the version of python used by default on your machine.

Looking at similar problems with node-pre-gyp (I saw a similar error messages with node-pre-gype here and here), it seems that this error might be related to the node-pre-gyp trying to use python 3.

@nolanmar511 can we force npm to use only Python 2 and bail if not found?

@kalyanac -- I don't know that there is an easy way to verify that Python 2 is available when needed.

We would only want to verify that Python 2 is present when node-pre-gyp fails to download pre-built binaries. If those binaries are available, it doesn't matter is Python 2 is available; if the binaries cannot be downloaded, node-pre-gyp is going to try to build the binaries from source right away (so, we can't then check if Python 2 is available).

We don't really have that much control over node-pre-gyp and node-gyp (the modules which we use for managing binaries).

@nolanmar511 Hi Margaret, my local macOS uses Python 3. I got it to install the node package. My prerequisite was to install pyenv so I can easily switch between Python versions.

Thanks!

I have sent #454 to update docs clarify that additional dependencies may be needed for installing @google-cloud/profiler.