Support for Elm installation when `--ignore-scripts` is enabled
DawidJanczak opened this issue · 2 comments
Hi,
We're migrating our project to 0.19 and are running into issues with the way the loader behaves when Elm binary is not installed (when --ignore-scripts
is passed to yarn/npm install
). In 0.18 we had to manually install Elm by running cd node_modules/elm && node install.js
, but now the whole process is easier and best described here: https://github.com/elm/compiler/blob/master/installers/npm/bin/elm#L3-L15
Now this works fine with a regular usage, however the first time we run the build it will always fail. Building the first file triggers the download and library installs, after which the other files build just fine, but the loader still fails the build for the first file. The whole process looks like this (logs from Google Cloud Build with verbose: true
passed to Elm compiler):
Step #1 - "webpack-build-assets": Running /var/app/node_modules/.bin/elm make /workspace/assets/components/elm/App1.elm --debug --output /tmp/11902-10-1v4fl4g.k3gu.js
Step #1 - "webpack-build-assets": Running /var/app/node_modules/.bin/elm make /workspace/assets/components/elm/App2.elm --debug --output /tmp/11902-10-5sgpg2.mket4.js
Step #1 - "webpack-build-assets": Starting downloads...
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": ● elm/json 1.1.2
Step #1 - "webpack-build-assets": ● elm/time 1.0.0
Step #1 - "webpack-build-assets": ● elm/core 1.0.0
Step #1 - "webpack-build-assets": ● elm/parser 1.1.0
Step #1 - "webpack-build-assets": ● elm/url 1.0.0
Step #1 - "webpack-build-assets": ● elm/browser 1.0.1
Step #1 - "webpack-build-assets": ● elm/http 1.0.0
Step #1 - "webpack-build-assets": ● elm/virtual-dom 1.0.2
Step #1 - "webpack-build-assets": ● elm/html 1.0.0
Step #1 - "webpack-build-assets": ● justinmimbs/date 3.1.2
Step #1 - "webpack-build-assets": ● elm-explorations/markdown 1.0.0
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": Verifying dependencies...
Building dependencies (1/11)
Building dependencies (2/11)
Building dependencies (3/11)
Building dependencies (4/11)
Building dependencies (5/11)
Building dependencies (6/11)
Building dependencies (7/11)
Building dependencies (8/11)
Building dependencies (9/11)
Building dependencies (10/11)
Building dependencies (11/11)
Dependencies ready!
Step #1 - "webpack-build-assets":
[======= ] - 1 / 7
[============== ] - 2 / 7
[===================== ] - 3 / 7
[============================ ] - 4 / 7
[=================================== ] - 5 / 7
[========================================== ] - 6 / 7
[==================================================] - 7 / 7
Success! Compiled 7 modules.
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": Running /var/app/node_modules/.bin/elm make /workspace/assets/components/elm/App3.elm --debug --output /tmp/11902-10-1ldjuqf.alk1.js
Step #1 - "webpack-build-assets":
[========================= ] - 1 / 2
[==================================================] - 2 / 2
Success! Compiled 2 modules.
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": Running /var/app/node_modules/.bin/elm make /workspace/assets/components/elm/App4.elm --debug --output /tmp/11902-10-uu3dzk.0vqw.js
Step #1 - "webpack-build-assets":
[==================================================] - 1 / 1
Success! Compiled 1 module.
(other modules follow, but it all fails later with the following)
Step #1 - "webpack-build-assets": + 468 hidden modules
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": ERROR in /workspace/assets/components/elm/App1.elm
Step #1 - "webpack-build-assets": Module build failed (from ./node_modules/elm-webpack-loader/index.js):
Step #1 - "webpack-build-assets": Error: Compiler process exited with error Compilation failed
Step #1 - "webpack-build-assets": -- NO elm.json FILE ------------------------------------------------------------
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": It looks like you are starting a new Elm project. Very exciting! Try running:
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": elm init
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": It will help you get set up. It is really simple!
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": at ChildProcess.<anonymous> (/var/app/node_modules/node-elm-compiler/index.js:149:27)
Step #1 - "webpack-build-assets": at ChildProcess.emit (events.js:182:13)
Step #1 - "webpack-build-assets": at maybeClose (internal/child_process.js:961:16)
Step #1 - "webpack-build-assets": at Socket.stream.socket.on (internal/child_process.js:380:11)
Step #1 - "webpack-build-assets": at Socket.emit (events.js:182:13)
Step #1 - "webpack-build-assets": at Pipe._handle.close (net.js:599:12)
Step #1 - "webpack-build-assets":
Step #1 - "webpack-build-assets": @ /workspace/assets/entry_points/entry_using_app1.js
For now we're working around this by running elm make <random_elm_file>
in our build scripts, but it would be good to avoid this.
this seems to be the closest to what i'm currently experiencing. I am trying to compile with webpack and elm-webpack-loader, and in a docker based container the compile always fails, but shortly after the failure of webpack, the process is still running it seems, as it downloads the dependencies, and compiles the file.
ERROR in ../service/src/elm/main/Main.elm
Module build failed (from ./node_modules/elm-webpack-loader/index.js):
Compiler process exited with error Compilation failed
@ ./src/js/communication/EventStreamManager.ts 12:12-60
@ ./src/js/routes/authenticated/CheckinRoute.tsx 12:0-70 117:4-34 188:42-60 242:4-31
@ ./src/js/routes/AuthenticatedRoute.tsx 44:48-91
@ ./src/js/Application.tsx 57:53-88
@ ./src/js/index.tsx 36:0-40 189:14-25
webpack 5.64.4 compiled with 1 error in 592554 ms
No issues found.
Running elm make /root/service/src/elm/main/Main.elm --debug --output /tmp/2022228-108-15dd3bg.7muo.js
Killed
error Command failed with exit code 137.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Success! 11ca:~/dashboard# Compiling ...
Main ───> /tmp/2022228-108-15dd3bg.7muo.js
I have tried compiling once then running webpack, which is the output above, but if I hadn't done that, you would also see the downloading of dependencies.
I have tried installing the linux binary for elm, but have the same behavior. I have no issues on mac os x.
@kelly-tock does this issue happen when running elm make
directly as well?
In my case, in CI, I'm running:
sysconfcpus -n 2 npx elm make src/elm/Main.elm
...and it fails:
Starting downloads...
● elm/bytes 1.0.8
● elm/file 1.0.5
● elm/random 1.0.0
...
● rtfeldman/elm-css 18.0.0
Verifying dependencies (30/31)Killed
Exited with code exit status 137
CircleCI received exit code 137
Sometimes it randomly works, but most times it does not. I'm at loss where that problem is coming from 😕