Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Failing to install under Alpine Linux #86

Closed
nathankellenicki opened this issue May 9, 2017 · 11 comments
Closed

Failing to install under Alpine Linux #86

nathankellenicki opened this issue May 9, 2017 · 11 comments
Assignees

Comments

@nathankellenicki
Copy link

Hi,

I'm attempting to use this inside a Docker container (Alpine Linux), however the install (npm install node-report) fails with this:

/usr/bin # npm install node-report

> node-report@2.1.2 install /usr/bin/node_modules/node-report
> node-gyp rebuild

make: Entering directory '/usr/bin/node_modules/node-report/build'
  CXX(target) Release/obj.target/api/src/node_report.o
../src/node_report.cc:45:22: fatal error: execinfo.h: No such file or directory
compilation terminated.
api.target.mk:105: recipe for target 'Release/obj.target/api/src/node_report.o' failed
make: *** [Release/obj.target/api/src/node_report.o] Error 1
make: Leaving directory '/usr/bin/node_modules/node-report/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.9.13-moby
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/bin/node_modules/node-report
gyp ERR! node -v v7.4.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/usr/bin/package.json'
npm WARN bin No description
npm WARN bin No repository field.
npm WARN bin No README data
npm WARN bin No license field.
npm ERR! Linux 4.9.13-moby
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "node-report"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE

npm ERR! node-report@2.1.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-report@2.1.2 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 node-report 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 node-report
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-report
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/bin/npm-debug.log

These are the build tools/deps I'm installing:

RUN apk update
RUN apk add \
        build-base \
        libtool \
        autoconf \
        automake \
        jq \
        openssh \
        python

Any ideas?

Thanks. :)

@nathankellenicki
Copy link
Author

@hhellyer
Copy link
Contributor

hhellyer commented May 10, 2017

I'm not familiar with Alpine Linux but doing a quick query on it's package manager suggests execinfo.h is part of libexecinfo-dev:
https://pkgs.alpinelinux.org/contents?file=execinfo.h&path=&name=&branch=&repo=&arch=

It provides the backtrace() function that we use to generate obtain the native stack at the point the report is created so it's a fairly key piece of function. Adding that package might resolve this issue.

Alpine linux looks like it tries to stay quite small so I wouldn't be surprised if you found another header missing further on but you might be able to find packages for the others the same way. If you are able to compile it let us know what you had to install, if it is able to build we might be able to add the info to the README.

@nathankellenicki
Copy link
Author

Thank you, that definitely helped. Turns out libexecinfo-dev is only available in the edge repo, so what I did is add the edge repo with the tag "edge" and use that tag to fetch it with apk. Like so:

RUN echo "@edge http://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories

RUN apk update
RUN apk add \
        build-base \
        libtool \
        autoconf \
        automake \
        jq \
        openssh \
        python \
        libexecinfo-dev@edge

Now installs fine. :)

@nathankellenicki
Copy link
Author

Just as an update to this, while install works now, execution doesn't. When included in a project, the process terminates with a message along the lines of "backtrace: symbol not found".

> node main.js

module.js:598
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: Error relocating /usr/src/app/node_modules/node-report/api.node: backtrace: symbol not found
    at Object.Module._extensions..node (module.js:598:18)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/src/app/node_modules/node-report/index.js:3:13)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

Some Googling suggests that this is because Alpine doesn't support glibc, and the Node.js inside the container isn't compiled with glibc or something (Not 100% sure on this).

For reference, I'm using the official Node.js Alpine Docker image:
https://github.com/nodejs/docker-node/blob/97fa0404116a7b6f926cd4c947199fbaea6d4e67/7.10/alpine/Dockerfile

My Dockerfile begins with:
FROM node:7.10.0-alpine

@rnchamberlain
Copy link
Contributor

rnchamberlain commented May 12, 2017

Looks like libexecinfo-dev should provide the backtrace function, maybe we need to add a library dependency to the node-report binding.gyp, for alpine.

Or maybe you'll need to install libexecinfo as well as libexecinfo-dev

@rnchamberlain
Copy link
Contributor

rnchamberlain commented May 24, 2017

@nathankunicki you are right, the problem is that Alpine does not support glibc, in particular the backtrace API that we use.

PR #89 raised. I tested on Linux alpine1 4.4.52-0-virtgrsec #1-Alpine SMP Tue Feb 28 10:27:10 GMT 2017 x86_64 Linux, node v6.9.5

@rnchamberlain rnchamberlain self-assigned this May 26, 2017
@rnchamberlain
Copy link
Contributor

@nathankunicki if you get a chance, could you try the fix in PR #89 on your Alpine environment:

npm install git://github.com/rnchamberlain/node-report.git#alpine-support

I needed to install git first (apk add git), and there were a couple of npm warnings about remote git, but node-report then worked OK for me. A simple test is node -r node-report foo where foo does not exist - a node-report is produced on the exception. Thanks!

@nathankellenicki
Copy link
Author

Apologies for the late response, I've gotten around to testing this now!

Node-report worked fine, but there's no call stack - I'm guessing since the libbacktrace functionality was ifdef'ed out.

I'm guessing it's a large amount of working to get it (and its dependencies) working in Alpine?

@rnchamberlain
Copy link
Contributor

Thanks, I will land the fix shortly. Yes, I just ifdef'ed out the code that calls the Linux backtrace api (http://man7.org/linux/man-pages/man3/backtrace.3.html) - as that is not available in Alpine. I think Alpine intentionally leave out quite a few libraries, to keep the footprint small. To get the backtrace working, possible solutions would need either a) our own native backtrace implementation, or b) bundle the missing libraries in node-report, or c) get a change to Alpine. All of those are quite a bit of work unfortunately, any suggestions welcome.

@rnchamberlain
Copy link
Contributor

PR #89 landed as 4691393

@pixelherodev
Copy link

Alpine supports execinfo / the backtrace function. I'm using it for my own project, found this issue by accident.

If you install libexecinfo-dev and link against libexecinfo.so, it works identically to when running under glibc.

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

No branches or pull requests

4 participants