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

Fails to install with official node 12 docker image #62

Closed
daveisfera opened this issue Sep 18, 2019 · 24 comments
Closed

Fails to install with official node 12 docker image #62

daveisfera opened this issue Sep 18, 2019 · 24 comments

Comments

@daveisfera
Copy link

Works with node 10:

> docker run --rm -it node:10.16.3-alpine yarn add newrelic
yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 23 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ @newrelic/[email protected]
├─ @newrelic/[email protected]
├─ @newrelic/[email protected]
├─ @tyriar/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 5.38s.

But fails with node 12:

> docker run --rm -it node:12.10.0-alpine yarn add newrelic
yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Error running install script for optional dependency: "/node_modules/@newrelic/native-metrics: Command failed.
Exit code: 1
Command: node ./lib/pre-build.js install native_metrics
Arguments: 
Directory: /node_modules/@newrelic/native-metrics
Output:
============================================================================
Attempting install in native-metrics module. Please note that this is an
OPTIONAL dependency, and any resultant errors in this process will not
affect the general performance of the New Relic agent, but event loop and
garbage collection metrics will not be collected.
============================================================================

> /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if \"python\" can be used
gyp ERR! find Python - \"python\" is not in PATH or produced an error
gyp ERR! find Python checking if \"python2\" can be used
gyp ERR! find Python - \"python2\" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python 2.7.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python=\"/path/to/pythonexecutable\"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python \"/path/to/pythonexecutable\"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https:/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:303:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:132:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:175:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:267:16)
gyp ERR! stack     at exithandler (child_process.js:302:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:314:5)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:456:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Linux 4.9.184-linuxkit
gyp ERR! command \"/usr/local/bin/node\" \"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"clean\" \"configure\"
gyp ERR! cwd /node_modules/@newrelic/native-metrics
gyp ERR! node -v v12.10.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok 
Failed to execute native-metrics install: No pre-built artifacts for your OS/architecture."
info This module is OPTIONAL, you can safely ignore this error
success Saved lockfile.
success Saved 21 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ @newrelic/[email protected]
├─ @newrelic/[email protected]
├─ @tyriar/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 4.97s.

Originally from node 12 support in the newrelic module

@astormnewrelic
Copy link
Contributor

@daveisfera Thanks for the heads up and good catch!

It looks like the official docker images don't have python installed and gyp needs python. The reason this works in node versions < 11 is we fall back to pre-built binaries when we can't compile the native metrics module.

Once we have formal support for 11/12 (which is coming, pinkie swear) we'll have a pre-built binaries for these newer node versions.

Thank you for bringing this to our attention.

@daveisfera
Copy link
Author

Any ETA on when this will be available?

@astormnewrelic
Copy link
Contributor

@daveisfera We can't comment officially about dates here for -- reasons. I can say it's on our roadmap and Node 11/12 support (including native metrics) is near the top of our priority list. If you need an official answer out of New Relic our official support channels are probably your best bet: https://support.newrelic.com/

@maxgalbu
Copy link

with the official node:12.10.0-stretch (not alpine), the build fails anyway with:

> @newrelic/[email protected] install /builds/hs-developers/bi-producer-redux/node_modules/@newrelic/native-metrics
> node ./lib/pre-build.js install native_metrics

> /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean configure
> /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build -j 1 native_metrics
make: Entering directory '/builds/hs-developers/bi-producer-redux/node_modules/@newrelic/native-metrics/build'
  CXX(target) Release/obj.target/native_metrics/src/native_metrics.o
In file included from ../node_modules/nan/nan_converters.h:67:0,
                 from ../node_modules/nan/nan.h:222,
                 from ../src/native_metrics.cpp:2:
../node_modules/nan/nan_converters_43_inl.h: In static member function 'static Nan::imp::ToFactoryBase<v8::Boolean>::return_t Nan::imp::ToFactory<v8::Boolean>::convert(v8::Local<v8::Value>)':
../node_modules/nan/nan_converters_43_inl.h:18:51: warning: 'v8::MaybeLocal<v8::Boolean> v8::Value::ToBoolean(v8::Local<v8::Context>) const' is deprecated: ToBoolean can never throw. Use Local version. [-Wdeprecated-declarations]
       val->To ## TYPE(isolate->GetCurrentContext())                            \
                                                   ^
../node_modules/nan/nan_converters_43_inl.h:22:1: note: in expansion of macro 'X'
 X(Boolean)
 ^
In file included from /root/.cache/node-gyp/12.10.0/include/node/v8-internal.h:14:0,
                 from /root/.cache/node-gyp/12.10.0/include/node/v8.h:25,
                 from /root/.cache/node-gyp/12.10.0/include/node/node.h:63,
                 from ../node_modules/nan/nan.h:53,
                 from ../src/native_metrics.cpp:2:
/root/.cache/node-gyp/12.10.0/include/node/v8.h:2537:59: note: declared here
                 V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
                                                           ^
/root/.cache/node-gyp/12.10.0/include/node/v8config.h:311:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../node_modules/nan/nan_converters.h:67:0,
                 from ../node_modules/nan/nan.h:222,
                 from ../src/native_metrics.cpp:2:
../node_modules/nan/nan_converters_43_inl.h: In static member function 'static Nan::imp::ValueFactoryBase<bool>::return_t Nan::imp::ToFactory<bool>::convert(v8::Local<v8::Value>)':
../node_modules/nan/nan_converters_43_inl.h:37:57: warning: 'v8::Maybe<bool> v8::Value::BooleanValue(v8::Local<v8::Context>) const' is deprecated: BooleanValue can never throw. Use Isolate version. [-Wdeprecated-declarations]
   return val->NAME ## Value(isolate->GetCurrentContext());                     \
                                                         ^
../node_modules/nan/nan_converters_43_inl.h:40:1: note: in expansion of macro 'X'
 X(bool, Boolean)
 ^
In file included from /root/.cache/node-gyp/12.10.0/include/node/v8-internal.h:14:0,
                 from /root/.cache/node-gyp/12.10.0/include/node/v8.h:25,
                 from /root/.cache/node-gyp/12.10.0/include/node/node.h:63,
                 from ../node_modules/nan/nan.h:53,
                 from ../src/native_metrics.cpp:2:
/root/.cache/node-gyp/12.10.0/include/node/v8.h:2575:51: note: declared here
                 V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(
                                                   ^
/root/.cache/node-gyp/12.10.0/include/node/v8config.h:311:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
In file included from ../node_modules/nan/nan_new.h:189:0,
                 from ../node_modules/nan/nan.h:223,
                 from ../src/native_metrics.cpp:2:
../node_modules/nan/nan_implementation_12_inl.h: In static member function 'static Nan::imp::FactoryBase<v8::StringObject>::return_t Nan::imp::Factory<v8::StringObject>::New(v8::Local<v8::String>)':
../node_modules/nan/nan_implementation_12_inl.h:356:37: error: no matching function for call to 'v8::StringObject::New(v8::Local<v8::String>&)'
   return v8::StringObject::New(value).As<v8::StringObject>();
                                     ^
In file included from /root/.cache/node-gyp/12.10.0/include/node/node.h:63:0,
                 from ../node_modules/nan/nan.h:53,
                 from ../src/native_metrics.cpp:2:
/root/.cache/node-gyp/12.10.0/include/node/v8.h:5394:23: note: candidate: static v8::Local<v8::Value> v8::StringObject::New(v8::Isolate*, v8::Local<v8::String>)
   static Local<Value> New(Isolate* isolate, Local<String> value);
                       ^~~
/root/.cache/node-gyp/12.10.0/include/node/v8.h:5394:23: note:   candidate expects 2 arguments, 1 provided
In file included from ../node_modules/nan/nan_new.h:189:0,
                 from ../node_modules/nan/nan.h:223,
                 from ../src/native_metrics.cpp:2:
../node_modules/nan/nan_implementation_12_inl.h:356:58: error: expected primary-expression before '>' token
   return v8::StringObject::New(value).As<v8::StringObject>();
                                                          ^
../node_modules/nan/nan_implementation_12_inl.h:356:60: error: expected primary-expression before ')' token
   return v8::StringObject::New(value).As<v8::StringObject>();
                                                            ^
In file included from /usr/include/c++/6/cassert:44:0,
                 from /root/.cache/node-gyp/12.10.0/include/node/node_object_wrap.h:26,
                 from ../node_modules/nan/nan.h:55,
                 from ../src/native_metrics.cpp:2:
../node_modules/nan/nan_object_wrap.h: In destructor 'virtual Nan::ObjectWrap::~ObjectWrap()':
../node_modules/nan/nan_object_wrap.h:24:25: error: 'class Nan::Persistent<v8::Object>' has no member named 'IsNearDeath'
     assert(persistent().IsNearDeath());
                         ^
../node_modules/nan/nan_object_wrap.h: In static member function 'static void Nan::ObjectWrap::WeakCallback(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)':
../node_modules/nan/nan_object_wrap.h:127:26: error: 'class Nan::Persistent<v8::Object>' has no member named 'IsNearDeath'
     assert(wrap->handle_.IsNearDeath());
                          ^
native_metrics.target.mk:116: recipe for target 'Release/obj.target/native_metrics/src/native_metrics.o' failed
make: Leaving directory '/builds/hs-developers/bi-producer-redux/node_modules/@newrelic/native-metrics/build'
make: *** [Release/obj.target/native_metrics/src/native_metrics.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:196:23)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 3.10.0-514.21.2.el7.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "-j" "1" "native_metrics"
gyp ERR! cwd /builds/hs-developers/bi-producer-redux/node_modules/@newrelic/native-metrics
gyp ERR! node -v v12.10.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok 
Error: Failed to execute install: Error: Failed to install module: Error: Failed to execute /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build -j 1 native_metrics: code 1; Error: Failed to download https://download.newrelic.com/nodejs_agent/builds/_newrelic_native_metrics-3_1_2-native_metrics-72-linux-x64.gz: code 404

@AndrewLeedham
Copy link

Getting a similar error with Circle CI's node 12 image using the new 5.0.0 release:

info This module is OPTIONAL, you can safely ignore this error
warning Error running install script for optional dependency: "/var/build/repo/node_modules/newrelic/node_modules/@newrelic/native-metrics: Command failed.
Exit code: 1
Command: node ./lib/pre-build.js install native_metrics
Arguments: 
Directory: /var/build/repo/node_modules/newrelic/node_modules/@newrelic/native-metrics
Output:
============================================================================
Attempting install in native-metrics module. Please note that this is an
OPTIONAL dependency, and any resultant errors in this process will not
affect the general performance of the New Relic agent, but event loop and
garbage collection metrics will not be collected.
============================================================================
2019-10-17T17:53:06.089965900Z 
> /usr/local/bin/node /var/build/repo/node_modules/node-gyp/bin/node-gyp.js clean configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 2.7.13 found at \"/usr/bin/python\"
gyp http GET https://nodejs.org/download/release/v12.9.1/node-v12.9.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v12.9.1/node-v12.9.1-headers.tar.gz
gyp ERR! Completion callback never invoked! 
gyp ERR! System Linux 4.9.184-linuxkit
gyp ERR! command \"/usr/local/bin/node\" \"/var/build/repo/node_modules/node-gyp/bin/node-gyp.js\" \"clean\" \"configure\"
gyp ERR! cwd /var/build/repo/node_modules/newrelic/node_modules/@newrelic/native-metrics
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v5.0.3
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https:/nodejs/node-gyp/issues>
Failed to execute native-metrics install: No pre-built artifacts for your OS/architecture."
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /var/build/repo/node_modules/@newrelic/native-metrics: Command failed.
Exit code: 1
Command: node ./lib/pre-build.js install native_metrics
Arguments: 
Directory: /var/build/repo/node_modules/@newrelic/native-metrics
Output:
============================================================================
Attempting install in native-metrics module. Please note that this is an
OPTIONAL dependency, and any resultant errors in this process will not
affect the general performance of the New Relic agent, but event loop and
garbage collection metrics will not be collected.
============================================================================
2019-10-17T17:53:06.362026300Z 
> /usr/local/bin/node /var/build/repo/node_modules/node-gyp/bin/node-gyp.js clean configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 2.7.13 found at "/usr/bin/python"
gyp http GET https://nodejs.org/download/release/v12.9.1/node-v12.9.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v12.9.1/node-v12.9.1-headers.tar.gz
gyp ERR! Completion callback never invoked! 
gyp ERR! System Linux 4.9.184-linuxkit
gyp ERR! command "/usr/local/bin/node" "/var/build/repo/node_modules/node-gyp/bin/node-gyp.js" "clean" "configure"
gyp ERR! cwd /var/build/repo/node_modules/@newrelic/native-metrics
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v5.0.3
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https:/nodejs/node-gyp/issues>
Failed to execute native-metrics install: No pre-built artifacts for your OS/architecture.

Using node 12.9 and circleci/node:12.9-browsers container. with @newrelic/native-metrics 5.0.0.

@astormnewrelic
Copy link
Contributor

Hey all -- in the interest of transparency, we're mid-stream on our Node 12 work. We have a new published version of the native metrics module that should build with Node 12. We do not, however, have our pre-built binaries in place yet which means if the build does fail (like @AndrewLeedham's did) then there's nothing to fall back on. We're working on getting those binaries in place, but for now if you see a build issue please let us know about it so we can determine if the problem's in our code or something else.

@AndrewLeedham -- looking over the build output

gyp http GET https://nodejs.org/download/release/v12.9.1/node-v12.9.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v12.9.1/node-v12.9.1-headers.tar.gz
gyp ERR! Completion callback never invoked! 
gyp ERR! System Linux 4.9.184-linuxkit
gyp ERR! command "/usr/local/bin/node" "/var/build/repo/node_modules/node-gyp/bin/node-gyp.js" "clean" "configure"
gyp ERR! cwd /var/build/repo/node_modules/@newrelic/native-metrics
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v5.0.3
gyp ERR! This is a bug in `node-gyp`.

This seems like it might be a problem related to the version of node-gyp in your build system, or node-gyp not being able to access a resource it needs from your CI environment?

@AndrewLeedham
Copy link

Hi @astormnewrelic thanks for getting back to me. Yes you are right it was an issue with a node-gyp dependency. Adding a resolution for tar 4.4.12 as discussed here nodejs/node-gyp#1887 fixed my issue.

@michaelgoin
Copy link
Member

Closing this issue out as we now have pre-built binaries to fall-back on and haven't found any issues with compilation that are not dependency related.

Feel free to re-open or open a new issue if other problems come up.

@daveisfera
Copy link
Author

I just did an npm install newrelic in the node:12.13.0-alpine docker image and I'm still getting an error:

# npm install newrelic

> @newrelic/[email protected] install /node_modules/@newrelic/native-metrics
> node ./lib/pre-build.js install native_metrics

============================================================================
Attempting install in native-metrics module. Please note that this is an
OPTIONAL dependency, and any resultant errors in this process will not
affect the general performance of the New Relic agent, but event loop and
garbage collection metrics will not be collected.
============================================================================

> /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean configure
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https:/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:302:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:314:5)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:456:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Linux 4.9.184-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "clean" "configure"
gyp ERR! cwd /node_modules/@newrelic/native-metrics
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
install successful: _newrelic_native_metrics-5_0_0-native_metrics-72-linux-x64
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ [email protected]
added 18 packages from 53 contributors, updated 1 package and audited 97 packages in 2.788s
found 0 vulnerabilities

@daveisfera
Copy link
Author

Also, it won't allow me to re-open the issue

@michaelgoin
Copy link
Member

@daveisfera I'll look into those package.json messages at the end... not sure why we are getting those.

Have you verified it is indeed not working?

The message install successful: _newrelic_native_metrics-5_0_0-native_metrics-72-linux-x64 implies the successful binary install after the compilation failed due to environment setup.

I'll go ahead and re-open so we can take a look.

@daveisfera
Copy link
Author

I had run npm install [email protected] first and then I noticed that 6.0.0 was released and gave that a try. Here's the output when running this clean:

# npm install newrelic

> @newrelic/[email protected] install /node_modules/@newrelic/native-metrics
> node ./lib/pre-build.js install native_metrics

============================================================================
Attempting install in native-metrics module. Please note that this is an
OPTIONAL dependency, and any resultant errors in this process will not
affect the general performance of the New Relic agent, but event loop and
garbage collection metrics will not be collected.
============================================================================

> /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean configure
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https:/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:302:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:314:5)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:456:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Linux 4.9.184-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "clean" "configure"
gyp ERR! cwd /node_modules/@newrelic/native-metrics
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
install successful: _newrelic_native_metrics-5_0_0-native_metrics-72-linux-x64
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ [email protected]
added 38 packages from 82 contributors and audited 50 packages in 4.66s
found 0 vulnerabilities

You can also reproduce this by running docker run --rm -it node:12.13.0-alpine sh and then running npm install newrelic

@michaelgoin
Copy link
Member

OK, we'll def take a look. If you have time, can you verify the native metrics aren't getting collected? Since the pre-built install might be successful given message prior to the package.json warnings I'm curious if this still end sup being mostly superficial.

If not, we'll try to get to it soon.

@daveisfera
Copy link
Author

We don't run newrelic in our development/testing environments because it's too expensive, so it will have to wait until the rest of the node 12 changes have been verified by QA and promoted to an environment where we run the agent

@michaelgoin
Copy link
Member

@daveisfera to confirm, were you running this inside the root of an initialized application? Or perhaps in an empty folder?

We can't repro the npm WARN saveError for a properly initialized Node app but we can if we install in a non-app directory.

We clearly have some work to see if we can make the successful fallback more obvious in the output.

But here's a description of what we are seeing in the output and confirmed for that last message...

  • The compile failures are due to the environment not having necessary dependency setup (python in this case).
  • Since the compile failed, we fall back to the pre-built binary which indicates it installed successfully via: install successful: _newrelic_native_metrics-5_0_0-native_metrics-72-linux-x64
  • npm gets unhappy because it was not installed inside a properly initialized node application and warns there is no package.json, etc. to update.

We've double-checked with [email protected] and [email protected] on node 12 alpine and looks to be working well.

Hopefully, this is just the case of the output being a little confusing.

@michaelgoin
Copy link
Member

Hi,

Since we haven't heard of any ongoing issues and this has been sitting a while, going to close it out. Feel free to reach out if you have further issues.

Thanks!

Michael

@derhyl
Copy link

derhyl commented Mar 31, 2020

I do confirm that this issue is still opened (with node 12 at least)

[2020-03-31T18:10:33.405Z] ERROR [15183] : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install

@newrelic/[email protected] install /tmp/deployment/application/node_modules/@newrelic/native-metrics
node ./lib/pre-build.js install native_metrics

@sunilkrishnatry
Copy link

I am also facing this same issue. My docker build is successful but I am getting this same error. Any updates or suggestion on this issue.

@astormnewrelic
Copy link
Contributor

@sunilkrishnatry The error output is expected. This is NPM logging that it couldn't manually build the native metrics module (which is a Node NAN/C++ base modules) and needed to fall back to downloading the pre-built binary. The native metrics module should still be a part of your system, and you should be getting the VM Page statistics it enables.

If we've misunderstood your question and your native metrics module is malfunctioning or the warnings displayed by NPM are somehow blocking you, your best best is to route this through New Relic's support channels: https://support.newrelic.com/

@eyedean
Copy link
Contributor

eyedean commented Aug 25, 2020

It was annoying for me as well! I am trying to install newrelic on node:alpine and I got the same warnings in the build time, which just looks nasty.

I did a lot of research on it, and here is what I found.

Three different errors

I saw a bunch of tickets like newrelic/node-newrelic#279 and this one, complaining about errors during installing npm i newrelic.

The first error in the first post of this thread is Could not find any Python installation to use.

The other error is in @maxgalbu's post, resulting in gyp ERR! build error and eventually Error: Failed to execute install: Error: Failed to install module.

The third one, which is a warning that I am getting on npm i newrelic on node:14-alpine (as well as node:12-alpine) is something like this:

> /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean configure
> /usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build -j 1 native_metrics
make: Entering directory '/usr/src/app/node_modules/@newrelic/native-metrics/build'
  CXX(target) Release/obj.target/native_metrics/src/native_metrics.o
In file included from ../src/native_metrics.cpp:7:
../../../nan/nan.h: In function 'void Nan::AsyncQueueWorker(Nan::AsyncWorker*)':
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from 'void (*)(uv_work_t*)' {aka 'void (*)(uv_work_s*)'} to 'uv_after_work_cb' {aka 'void (*)(uv_work_s*, int)'} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
In file included from ../../../nan/nan.h:56,
                 from ../src/native_metrics.cpp:7:
../src/native_metrics.cpp: At global scope:
/root/.cache/node-gyp/14.8.0/include/node/node.h:746:43: warning: cast between incompatible function types from 'void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void (*)(v8::Local<v8::Object>)'} to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
  746 |       (node::addon_register_func) (regfunc),                          \
      |                                           ^
/root/.cache/node-gyp/14.8.0/include/node/node.h:780:3: note: in expansion of macro 'NODE_MODULE_X'
  780 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/native_metrics.cpp:22:1: note: in expansion of macro 'NODE_MODULE'
   22 | NODE_MODULE(native_metrics, Init)
      | ^~~~~~~~~~~
  CXX(target) Release/obj.target/native_metrics/src/GCBinder.o
In file included from ../src/GCBinder.hpp:9,
                 from ../src/GCBinder.cpp:7:
../../../nan/nan.h: In function 'void Nan::AsyncQueueWorker(Nan::AsyncWorker*)':
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from 'void (*)(uv_work_t*)' {aka 'void (*)(uv_work_s*)'} to 'uv_after_work_cb' {aka 'void (*)(uv_work_s*, int)'} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
  CXX(target) Release/obj.target/native_metrics/src/LoopChecker.o
In file included from ../src/LoopChecker.hpp:8,
                 from ../src/LoopChecker.cpp:10:
../../../nan/nan.h: In function 'void Nan::AsyncQueueWorker(Nan::AsyncWorker*)':
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from 'void (*)(uv_work_t*)' {aka 'void (*)(uv_work_s*)'} to 'uv_after_work_cb' {aka 'void (*)(uv_work_s*, int)'} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
  CXX(target) Release/obj.target/native_metrics/src/RUsageMeter.o
In file included from ../src/RUsageMeter.cpp:8:
../../../nan/nan.h: In function 'void Nan::AsyncQueueWorker(Nan::AsyncWorker*)':
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from 'void (*)(uv_work_t*)' {aka 'void (*)(uv_work_s*)'} to 'uv_after_work_cb' {aka 'void (*)(uv_work_s*, int)'} [-Wcast-function-type]
 2294 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |                                                              ^
  SOLINK_MODULE(target) Release/obj.target/native_metrics.node
  COPY Release/native_metrics.node
make: Leaving directory '/usr/src/app/node_modules/@newrelic/native-metrics/build'
install successful: _newrelic_native_metrics-5_3_0-native_metrics-83-linux-x64

(Note that there is a line of install successful: ... at the end!)

Fixing Python Not Found Error

Well, Alpine is so minimal that it doesn't come with python. You can simply add RUN apt add python make g++ (detail version here: nodejs/docker-node#282 or here). That should be it!

Where do nan error/warnings come from?

The reason it's not happening for everyone is:

  • New Relic uses Node Native metrics (this sub-package) to collect native layer metrics for NR Agent.
  • Native Metrics, has some C++ code in it, so it needs a tool to compile these C++ addon modules for Node.js. Native Metrics uses nan (Don't confuse is with JavaScript's NaN ;D) for the headerfile it provides, and nan internally depends on node-gyp for the actual job.
  • Now, node-gyp, which is a tool for compiling native addon modules for Node.js, needs a compiler from the OS. The problem here is Alpine uses musl libc instead of glibc and most popular distros use the latter. That's why you don't see this issue on your local machine and on other docker images (e.g. stretch).

Solutions:

On problem #2 and #3, depending on whether the last line is install successful or Failed to execute native-metrics install, you have Warnings or Error.

For the nan error:

  1. You can try to install glibc on Alpine to solve other similar problems, but it's controversial. See this Stackoverflow question and answers, or get a custom build of node-pre-gyp with musl as libc per here.
  2. Don't hate me, but you might want to consider switching to a non-alpine distribution if you can and save the similar problem on other packages! (e.g. bcrypt, etc.)

For the nan warnings:

  1. It's apparently safe to ignore, both per @astormnewrelic and @michaelgoin here, and also nan's warning: cast between incompatible function types (Node 12) nodejs/nan#878, as they are just Warnings, and they are known. So, You can simply ignore them!
  2. If you don't want your docker build to have these scary lines pointing to some actual C++ code, you can suppress this warning locally via RUN CXXFLAGS="-Wno-cast-function-type" npm i newrelic (before your npm i for all packages) in your Dockerfile. This will suppress those warnings solely during the installation of newrelic package. (inspired by Is is possible to work around -Wcast-function-type warnings produced by Nan? lovell/sharp#1802)
  3. Someone can open a PR and add "cflags_cc": [ "-Wno-cast-function-type" ] to binding.gyp of this package. That's exactly what DataDog guys have done at https:/DataDog/dd-trace-js/pull/943/files to make it less scary for typical users. :)

Hope it helps!

@astormnewrelic
Copy link
Contributor

💥 Thanks the deep dive @eyedean -- that's great troubleshooting and great information. Assuming it doesn't cause problems on any of our supported platforms we'd be super-open to a PR that added the -Wno-cast-function-type options to our compiler flags for this project.

@eyedean Regarding getting glibc on Alpine or using a custom build of node-pre-gyp -- do you happen to have any sample Dockerfiles lying around with a working recipe? Or is this a "read the links you posted" situation? ;)

eyedean added a commit to eyedean/node-native-metrics that referenced this issue Aug 26, 2020
@eyedean
Copy link
Contributor

eyedean commented Aug 26, 2020

Thanks for your response @astormnewrelic. I am glad that it helped! :)

I created this PR: #112, but wasn't very successful in building and testing in inside docker containers (I don't have a linux machine around). Left notes at #112 (comment). I hope it still helps.

Regarding glibc on Alpine, I actually tried this one, but didn't work for me. I guess that's the place to start, but I cannot afford to put more time on it. :)

Thanks.

@rnarayana
Copy link

I had to apk add python3 instead of simply python in an alpine distro to make it work.

@michaelgoin
Copy link
Member

I feel like the bad guy that is constantly coming in and closing this issue and... here I am once again.

Some incremental improvement was landed above. Overall, this is an environment compilation issue we aren't currently planning on trying to improve with our priorities. Thank you to everyone for adding your solution notes to the issue. If some specific documentation would be helpful, let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

9 participants