compiler
compiler copied to clipboard
Cannot compile with ELM inside Docker on Mac M1
I'm trying to use ELM to compile a Vue App, which is inside a Docker Container, this works on Linux and Mac Intel.
- Elm: 0.19.1
-
Operating System:
Model Name: MacBook Pro Model Identifier: MacBookPro18,3 Chip: Apple M1 Pro Total Number of Cores: 8 (6 performance and 2 efficiency) Memory: 16 GB System Firmware Version: 7429.81.3 OS Loader Version: 7429.81.3
Additional Details
- I have tried to use
v0.19.1-4
for NPM - I tried to install
0.19.1/binary-for-linux-64-bit.gz
in the container before installing NPM - I'm using Docker
nginx:stable-alpine
Error
ERROR in ./src/elm/Main.elm
Module build failed: Error: Compiler process exited with error Compilation failed
at ChildProcess.<anonymous> (/app/node_modules/node-elm-compiler/dist/index.js:131:35)
at ChildProcess.emit (events.js:400:28)
at ChildProcess.emit (domain.js:475:12)
at maybeClose (internal/child_process.js:1058:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Socket.emit (events.js:400:28)
at Socket.emit (domain.js:475:12)
at Pipe.<anonymous> (net.js:686:12)
Thanks for reporting this! To set expectations:
- Issues are reviewed in batches, so it can take some time to get a response.
- Ask questions in a community forum. You will get an answer quicker that way!
- If you experience something similar, open a new issue. We like duplicates.
Finally, please be patient with the core team. They are trying their best with limited resources.
I am also coming across this problem. It seems that OOM killer kills elm compiler process. Around 10GB are being consumed in my case, but sometimes not. It's realy unstable.
What is your Docker preference about CPU, memory, and swap?
I have the same problem and was able to build Elm using the following article: https://dev.to/csaltos/elm-for-linux-arm64-32bc
This is a hugely frustrating issue because the information available is very patchy, not particularly helped by the 0.19.1-4 or 0.19.1-5 approaches (i.e. 0.19.1-4 doesn't actually work), and is compounded with issues where the docker daemon itself is crashing due to memory issues in the scenario @IzumiSy mentions.
I've successfully built binaries using the approach @ream88 mentions, however the binary isn't statically compiled and hence won't run, for example, on alpine. I've yet to manage to get a build working on alpine, I know zero about the Haskell tooling. if anyone can share insights on how to produce a portable binary here, it would be hugely appreciated
I should also mention I've been able to install via nix-env, but then nix isn't particularly easy to install either.
I'm running Elm inside Docker in a Mac M1 and it seems to work by installing it like this:
RUN curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz \
&& gunzip elm.gz \
&& chmod +x elm \
&& mv elm /usr/local/bin/
The only problem so far is that compilation takes a few seconds to start (was instantaneous in the Intel Mac)
@sashaafm Elm still dies OoM for me with this suggestion. What base image are you using? I've tried ubuntu and alpine.
@bwells I'm using the elixir:1.11
base image
@bwells back when I posted this I was only using an M1 Mac with 16GB RAM. I now started using an M1 Mac with 8GB and did a full migration from the other Mac. In this 8GB Mac I lowered the memory limit in Docker to 4GB since I didn't want to use as many resources as the other one. However, Elm compilation started failing with OOM like you described.
I found out that setting the limit to 8GB back again now works for the 8GB Mac as well. So I guess that Elm compilation in the M1 Macs require at least 8GB of memory in order to not be killed? I don't see the memory pressure going to those limits though
Thanks so much for reaching out. I was able to determine that raising the Docker VM memory limit to 7GB with my codebase would allow successful compiles. I'm on a 24 GB M2 Air these days, so that amount of memory is workable, but still feels a bit silly.
I also don't actually see the memory pressure triggering the OOM kill and this still feels like room for improvement out of Elm and/or Haskell, but I'm glad to have a working solution again.