The elm
project I'm working on with yarn
on nixos
I cannot get to compile. This project compiles successfully for my colleagues who are using macOS; perhaps the failure to compile on my machine is related to my using NixOS.
When I run $ yarn start
I get the following terminal output:
$ yarn start
yarn start v0.20.3
$ webpack-dev-server --env dev
env dev
Project is running at http://0.0.0.0:3000/
webpack output is served from /
Content not from webpack is served from /home/matthew/backup/azara_work/platform/web/src
404s will fallback to /index.html
Running elm-make /home/matthew/backup/azara_work/platform/web/src/App.elm --yes --warn --debug --output /tmp/117814-7766-1wq3nh5.xanii6yldi.js
and when I attempt to load the page at http://0.0.0.0:3000/
my browser console shows the following errors:
VM1496:1 Uncaught Error: Module build failed: Error: Compiler process exited with error Compilation failed
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn /home/matthew/backup/azara_work/platform/web/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:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
at ChildProcess.<anonymous> (/home/matthew/backup/azara_work/platform/web/node_modules/node-elm-compiler/index.js:141:27)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Socket.<anonymous> (internal/child_process.js:342:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)
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:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
at ChildProcess.<anonymous> (/home/matthew/backup/azara_work/platform/web/node_modules/node-elm-compiler/index.js:141:27)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Socket.<anonymous> (internal/child_process.js:342:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)
at eval (eval at ./src/App.elm (http://0.0.0.0:3000/index.js:4316:1), <anonymous>:1:7)
at Object../src/App.elm (http://0.0.0.0:3000/index.js:4316:1)
at __webpack_require__ (http://0.0.0.0:3000/index.js:658:30)
at fn (http://0.0.0.0:3000/index.js:86:20)
at eval (eval at ./src/index.js (http://0.0.0.0:3000/index.js:4324:1), <anonymous>:7:13)
at Object../src/index.js (http://0.0.0.0:3000/index.js:4324:1)
at __webpack_require__ (http://0.0.0.0:3000/index.js:658:30)
at fn (http://0.0.0.0:3000/index.js:86:20)
at Object.0 (http://0.0.0.0:3000/index.js:4333:18)
at __webpack_require__ (http://0.0.0.0:3000/index.js:658:30)
and
./src/App.elm
Module build failed: Error: Compiler process exited with error Compilation failed
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn /home/matthew/backup/azara_work/platform/web/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:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
at ChildProcess.<anonymous> (/home/matthew/backup/azara_work/platform/web/node_modules/node-elm-compiler/index.js:141:27)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Socket.<anonymous> (internal/child_process.js:342:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)
@ ./src/index.js 2:12-32
@ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server ./src/index.js
It appears that the problem may have something to do with elm-make
, since that appears in both errors. My path finds elm-make
at
$ which elm-make
/home/matthew/.nix-profile/bin/elm-make
which is a different location than the path at which the error reports it is trying to find elm-make
(/home/matthew/backup/azara_work/platform/web/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make
). I am wondering if that might be related to the problem.
In the directory listed in the error, elm-make
does appear to be present when listing via ls
:
$ ls /home/matthew/backup/azara_work/platform/web/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/
elm elm-make elm-package elm-reactor elm-repl
However, when I try to run the command listed in yarn start
's output, except replacing elm-make
with the elm-make at this node-modules path, I get a 'No such file or directory' error.
$ ./node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make /home/matthew/backup/azara_work/platform/web/src/App.elm --yes --warn --debug --output /tmp/117814-7422-1p5ad15.q2uqqzd7vi.js
-bash: ./node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make: No such file or directory
Why might I get this 'No such file or directory' error when attempting to run this 'node-modules' elm-make
when the executable is clearly visible when listing via ls
?
Is the failure to compile due to the difference in path locations between my path's elm-make
and the other one under 'node-modules'? Perhaps yarn is using the wrong one. If so, how can I set yarn to use the correct elm-make
?
How might I get yarn start
to successfully compile the project?
Advice is much appreciated; I've been stuck on this for a while.
I suggest you make elm installation optional (somehow) for NixOS. Usually easiest if you create a shell.nix that everyone uses and avoid depending on nix via npm at all.
The reason why elm-make doesn't exist is due to ELF interpreter, which is located at different place for NixOS.
Try ldd ./node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make
Quick fix would be to symlink all binaries in ls -la $(nix-build -A elmPackages.elm '<nixpkgs>')/bin
to your cabal sandbox.