purescript / npm-installer

ISC License
10 stars 13 forks source link

alpine linux: Failed at the purescript@0.13.2 postinstall script #16

Closed javier-cornejo closed 4 years ago

javier-cornejo commented 5 years ago

Trying to run npm i -g purescript

On alpine:3.10.1 in a docker container. node v10.16.0 npm v6.9.0

716 verbose stack Error: purescript@0.13.2 postinstall: install-purescript --purs-ver=0.13.2 716 verbose stack Exit status 1 716 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16) 716 verbose stack at EventEmitter.emit (events.js:198:13) 716 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 716 verbose stack at ChildProcess.emit (events.js:198:13) 716 verbose stack at maybeClose (internal/child_process.js:982:16) 716 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

Also attaching a log file: 2019-07-14T03_13_09_728Z-debug.log

javier-cornejo commented 5 years ago

Screenshot from 2019-07-13 22-35-44

hdgarrood commented 5 years ago

Thanks for the report. Do you have a minimal Dockerfile which can reproduce this issue?

javier-cornejo commented 5 years ago

Sure, Fedora release 30 (Thirty) Docker version 18.09.7, build 2d0083d

FROM alpine:3.10.1

RUN apk add nodejs npm && \
    npm install --global purescript
javier-cornejo commented 5 years ago

This one shows more errors at docker build time

FROM alpine:3.10.1

RUN apk add nodejs npm && \
    npm install --global --ignore-scripts purescript && \
    node /usr/lib/node_modules/purescript/node_modules/purescript-installer/index.js
marijnz0r commented 5 years ago

I'm affected by this issue as well on:

↓ Fallback: building from source

✖ Check if 'stack' command is available stack --allow-different-user --numeric-version Error: Command failed with exit code 2 (ENOENT): stack --allow-different-user --numeric-version spawn stack ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19) at onErrorNT (internal/child_process.js:456:16) at processTicksAndRejections (internal/process/task_queues.js:80:21) ▬ Download the PureScript 0.13.4 source ▬ Ensure the appropriate GHC is installed ▬ Build a binary from source ▬ Save the built binary to the npm cache directory

hdgarrood commented 5 years ago

@marijnz0r that looks like a different issue to me, it seems you're missing the libtinfo / ncurses library. See the note in https://github.com/purescript/purescript/blob/master/INSTALL.md#the-curses-library

marijnz0r commented 5 years ago

@hdgarrood thanks for the quick response, it seems it might have to do something with a correct version of libtinfo, check out this issue: https://github.com/spacchetti/spago/issues/104 Do you have an idea how to fix this?

hdgarrood commented 5 years ago

Yes, you need to install the ncurses/libtinfo library, and/or build from source so that GHC can select the appropriate version.

marijnz0r commented 5 years ago

The weird thing is, I do have them installed:

locate libtinfo.so
/snap/core/7713/lib/x86_64-linux-gnu/libtinfo.so.5
/snap/core/7713/lib/x86_64-linux-gnu/libtinfo.so.5.9
/snap/core/7917/lib/x86_64-linux-gnu/libtinfo.so.5
/snap/core/7917/lib/x86_64-linux-gnu/libtinfo.so.5.9
/snap/core18/1192/lib/x86_64-linux-gnu/libtinfo.so.5
/snap/core18/1192/lib/x86_64-linux-gnu/libtinfo.so.5.9
/snap/core18/1223/lib/x86_64-linux-gnu/libtinfo.so.5
/snap/core18/1223/lib/x86_64-linux-gnu/libtinfo.so.5.9
/usr/lib/x86_64-linux-gnu/libtinfo.so
/usr/lib/x86_64-linux-gnu/libtinfo.so.6
/usr/lib/x86_64-linux-gnu/libtinfo.so.6.1

How do I point the purescript install script to the correct libtinfo.so.5?

marijnz0r commented 5 years ago

This apparently fixed it for me:

sudo ln -s /snap/core/7917/lib/x86_64-linux-gnu/libtinfo.so.5 /usr/lib/x86_64-linux-gnu/libtinfo.so.5

I hope it helps someone.

hdgarrood commented 5 years ago

You can use LD_LIBRARY_PATH, or preferably put the library in one of the directories listed in /etc/ld.so.conf. See http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

hdgarrood commented 4 years ago

I've dug into this a bit and I think it might be to do with alpine being based on musl rather than glibc or some other difference in how the system is set up. After running those commands, we get an error along the lines of spawn /purs ENOENT, which would suggest that the problem is that the file /purs does not exist. In fact the file does exist, which leads me to believe that we are in a similar situation to this person: https://stackoverflow.com/questions/5234088/execve-file-not-found-when-stracing-the-very-same-file, and the ENOENT really means that the dynamic loader for the binary doesn't exist. Indeed, ldd /purs prints /lib64/ld-linux-x86-64.so.2 as the first line of the output, but no such file that exists in the container. I think you may need to build the compiler from source.

hdgarrood commented 4 years ago

The issues reported here are covered by #22 and #24, so I'm going to close this. Thanks for the report!

wclr commented 3 years ago

@hdgarrood (Form the discussion) it is not clear what to do if one wants to install purs on alpine and encounters the error?

Should this be added to https://github.com/purescript/purescript/blob/master/INSTALL.md ?

hdgarrood commented 3 years ago

You’ll need to build the compiler yourself from source on alpine, as all of the prebuilt binaries rely on glibc. We do have instructions there for building from source already, but I don’t think we have the bandwidth to maintain instructions for alpine specifically.