elm-lang / elm-platform

Bundle of all core development tools for Elm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot get elm-make to run on Alpine Linux

sashaafm opened this issue · comments

Hello, I've been trying to build a Docker image for a project which uses Elm, and I cannot get elm-make to work no matter what.

I'm adding and installing npm and elm like this:

RUN apk update
RUN apk add nodejs nodejs-npm \
&& npm install -g elm

And then I get into the container and I'm trying to build the source like so:

/app # elm-make elm_src/Main.elm --output app.js
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn /usr/lib/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make ENOENT
    at exports._errnoException (util.js:1018:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:505:3

I've seen several threads and forums regarding issues similar to this, but they're usually directed at Ubuntu/Debian, and so far no solution worked for me.

I've tried installing locally once inside the container and this is the result:

/app # apk update \
> && apk add nodejs nodejs-npm \
> && npm install elm
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.2-118-g57a88ee6b0 [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.2-119-ga84f2c0b45 [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
OK: 8440 distinct packages available
OK: 86 MiB in 40 packages
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead

> elm@0.18.0 install /app/node_modules/elm
> node install.js

Downloading Elm binaries from https://dl.bintray.com/elmlang/elm-platform/0.18.0/linux-x64.tar.gz
/app
`-- elm@0.18.0
  +-- mkdirp@0.5.1
  | `-- minimist@0.0.8
  +-- promise@7.1.1
  | `-- asap@2.0.6
  +-- request@2.74.0
  | +-- aws-sign2@0.6.0
  | +-- aws4@1.6.0
  | +-- bl@1.1.2
  | | `-- readable-stream@2.0.6
  | |   +-- core-util-is@1.0.2
  | |   +-- isarray@1.0.0
  | |   +-- process-nextick-args@1.0.7
  | |   +-- string_decoder@0.10.31
  | |   `-- util-deprecate@1.0.2
  | +-- caseless@0.11.0
  | +-- combined-stream@1.0.5
  | | `-- delayed-stream@1.0.0
  | +-- extend@3.0.1
  | +-- forever-agent@0.6.1
  | +-- form-data@1.0.1
  | | `-- async@2.5.0
  | |   `-- lodash@4.17.4
  | +-- har-validator@2.0.6
  | | +-- chalk@1.1.3
  | | | +-- ansi-styles@2.2.1
  | | | +-- escape-string-regexp@1.0.5
  | | | +-- has-ansi@2.0.0
  | | | | `-- ansi-regex@2.1.1
  | | | +-- strip-ansi@3.0.1
  | | | `-- supports-color@2.0.0
  | | +-- commander@2.11.0
  | | +-- is-my-json-valid@2.16.1
  | | | +-- generate-function@2.0.0
  | | | +-- generate-object-property@1.2.0
  | | | | `-- is-property@1.0.2
  | | | +-- jsonpointer@4.0.1
  | | | `-- xtend@4.0.1
  | | `-- pinkie-promise@2.0.1
  | |   `-- pinkie@2.0.4
  | +-- hawk@3.1.3
  | | +-- boom@2.10.1
  | | +-- cryptiles@2.0.5
  | | +-- hoek@2.16.3
  | | `-- sntp@1.0.9
  | +-- http-signature@1.1.1
  | | +-- assert-plus@0.2.0
  | | +-- jsprim@1.4.1
  | | | +-- assert-plus@1.0.0
  | | | +-- extsprintf@1.3.0
  | | | +-- json-schema@0.2.3
  | | | `-- verror@1.10.0
  | | |   `-- assert-plus@1.0.0
  | | `-- sshpk@1.13.1
  | |   +-- asn1@0.2.3
  | |   +-- assert-plus@1.0.0
  | |   +-- bcrypt-pbkdf@1.0.1
  | |   +-- dashdash@1.14.1
  | |   | `-- assert-plus@1.0.0
  | |   +-- ecc-jsbn@0.1.1
  | |   +-- getpass@0.1.7
  | |   | `-- assert-plus@1.0.0
  | |   +-- jsbn@0.1.1
  | |   `-- tweetnacl@0.14.5
  | +-- is-typedarray@1.0.0
  | +-- isstream@0.1.2
  | +-- json-stringify-safe@5.0.1
  | +-- mime-types@2.1.17
  | | `-- mime-db@1.30.0
  | +-- node-uuid@1.4.8
  | +-- oauth-sign@0.8.2
  | +-- qs@6.2.3
  | +-- stringstream@0.0.5
  | +-- tough-cookie@2.3.2
  | | `-- punycode@1.4.1
  | `-- tunnel-agent@0.4.3
  `-- tar@2.2.1
    +-- block-stream@0.0.9
    +-- fstream@1.0.11
    | +-- graceful-fs@4.1.11
    | `-- rimraf@2.6.1
    |   `-- glob@7.1.2
    |     +-- fs.realpath@1.0.0
    |     +-- inflight@1.0.6
    |     | `-- wrappy@1.0.2
    |     +-- minimatch@3.0.4
    |     | `-- brace-expansion@1.1.8
    |     |   +-- balanced-match@1.0.0
    |     |   `-- concat-map@0.0.1
    |     +-- once@1.4.0
    |     `-- path-is-absolute@1.0.1
    `-- inherits@2.0.3

npm WARN enoent ENOENT: no such file or directory, open '/app/package.json'
npm WARN app No description
npm WARN app No repository field.
npm WARN app No README data
npm WARN app No license field.

And running elm-make which yields the same error.

If someone could help with this I'd be most thankful. For the time being I'm going to try using a Debian base image, but I'd really rather use an Alpine base.

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

having the exact same issue, any updates?

We're encountering the same kind of error. I guess we're going to switch to another system too :(

I have run into this lately as well

Directly pulling the binaries into an image based on Alpine 3.6, adding gmp, then interactively running a container and issuing ldd ./elm-make reports:
Error relocating ./elm-make: __printf_chk: symbol not found
Error relocating ./elm-make: __vfprintf_chk: symbol not found
Error relocating ./elm-make: __strncpy_chk: symbol not found
Error relocating ./elm-make: __sprintf_chk: symbol not found
Error relocating ./elm-make: __fdelt_chk: symbol not found
Error relocating ./elm-make: __fprintf_chk: symbol not found
Error relocating ./elm-make: __memcpy_chk: symbol not found

I believe these symbols are native to glibc, whereas Alpine's libc is musl and does not support them

There is an APK that can be added that will provide glibc here; unfortunately it is unavailable in the official repository.
I have an example Dockerfile with elm-make building hello-world.elm here. Hopefully this can help someone else out; unfortunately for my case I'm unlikely to be able to use an APK unavailable in the official repository.

commented

The same problem here.

It seems this is due to how GHC generates code. I know they do no dynamic linking of Haskell code, but they do some with C code, so I suspect @mckinley-olsen-oc is the best advice you can get without talking to GHC people.

I cannot figure out any concrete action items based on this, so I am going to close.

In case anyone runs into this I solved it by using https://github.com/frol/docker-alpine-glibc and apk add --no-cache gmp yarn && yarn global add elm@0.18.0.

My full Dockerfile including a unprivileged user.

FROM frolvlad/alpine-glibc

RUN set -ex \
    && apk add --no-cache shadow \
    && groupadd -g 9999 deploy \
    && useradd -r -u 9999 -g deploy deploy \
    && apk del shadow \
    && mkdir /home/deploy \
    && chown deploy:deploy /home/deploy \
    && mkdir /app \
    && chown deploy:deploy /app

RUN apk add --no-cache gmp yarn

WORKDIR /app

RUN yarn global add elm@0.18.0

USER deploy

Edit: Noticed mckinley-olsen-oc had a similar suggestion above (https://github.com/mckinley-olsen-oc/alpine-elm/blob/master/Dockerfile).

commented

I asked somebody how we could solve this problem.in elm and he gave me this hint:

@andys8 I imagine a common solution to be to compile your program on Alpine, and link it statically.
Then it will work on Alpine as well as pretty much every Linux system in existence.

@sashaafm @littleStudent @Bastes @mckinley-olsen-oc @joakimk @andys8

Hello folks!

It seems that I solved this problem. Please, check out this links:

https://github.com/wunsh/docker-alpine-elm
https://hub.docker.com/r/wunsh/alpine-elm/

This is pure Alpine 3.7 image with built Elm 0.18.

I also have another solution using Yarn, but I think this is no so interesting like pure Alpine with Elm binaries above.

If you try to deploy your Elm app with now to zeit.co this might be helpful for you: https://github.com/synalysis/deploy-elm-now-zeit

elm-make creates a coredump on zeit.co (Alpine Linux) when deploying with now without Dockerfile.