Home > other >  Heroku deployment of Scala app fails with: Cannot run program "node"
Heroku deployment of Scala app fails with: Cannot run program "node"

Time:08-12

I'm trying to deploy a Scala/Play app to Heroku using sbt, but I keep getting the following error:

remote: Downloaded https://repo1.maven.org/maven2/org/typelevel/machinist_sjs0.6_2.12/0.6.2/machinist_sjs0.6_2.12-0.6.2.jar
remote:        [info] Compiling 626 Scala sources to /tmp/scala_buildpack_build_dir/shared/.js/target/scala-2.12/classes...
remote:        [info] LESS compiling on 3 source(s)
remote:        [ERROR] [08/11/2022 14:30:33.182] [sbt-web-akka.actor.default-dispatcher-8] [akka://sbt-web/user/$b/process] null
remote:        akka.actor.ActorInitializationException: exception during creation
remote:         at akka.actor.ActorInitializationException$.apply(Actor.scala:166)
remote:         at akka.actor.ActorCell.create(ActorCell.scala:596)
remote:         at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:456)
remote:         at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
remote:         at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:263)
remote:         at akka.dispatch.Mailbox.run(Mailbox.scala:219)
remote:         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
remote:         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
remote:         at java.lang.Thread.run(Thread.java:750)
remote:        Caused by: java.lang.reflect.InvocationTargetException
remote:         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
remote:         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
remote:         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
remote:         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
remote:         at akka.util.Reflect$.instantiate(Reflect.scala:66)
remote:         at akka.actor.ArgsReflectConstructor.produce(Props.scala:355)
remote:         at akka.actor.Props.newActor(Props.scala:255)
remote:         at akka.actor.ActorCell.newActor(ActorCell.scala:552)
remote:         at akka.actor.ActorCell.create(ActorCell.scala:578)
remote:         ... 7 more
remote:        Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
remote:         at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
remote:         at akka.contrib.process.BlockingProcess.<init>(BlockingProcess.scala:55)
remote:         ... 16 more
remote:        Caused by: java.io.IOException: error=2, No such file or directory
remote:         at java.lang.UNIXProcess.forkAndExec(Native Method)
remote:         at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
remote:         at java.lang.ProcessImpl.start(ProcessImpl.java:134)
remote:         at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
remote:         ... 17 more
remote:
remote:        [ERROR] [08/11/2022 14:30:33.183] [sbt-web-akka.actor.default-dispatcher-4] [akka://sbt-web/user/$a/process] null
remote:        akka.actor.ActorInitializationException: exception during creation
remote:         at akka.actor.ActorInitializationException$.apply(Actor.scala:166)
remote:         at akka.actor.ActorCell.create(ActorCell.scala:596)
remote:         at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:456)
remote:         at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
remote:         at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:263)
remote:         at akka.dispatch.Mailbox.run(Mailbox.scala:219)
remote:         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
remote:         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
remote:         at java.lang.Thread.run(Thread.java:750)
remote:        Caused by: java.lang.reflect.InvocationTargetException
remote:         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
remote:         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
remote:         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
remote:         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
remote:         at akka.util.Reflect$.instantiate(Reflect.scala:66)
remote:         at akka.actor.ArgsReflectConstructor.produce(Props.scala:355)
remote:         at akka.actor.Props.newActor(Props.scala:255)
remote:         at akka.actor.ActorCell.newActor(ActorCell.scala:552)
remote:         at akka.actor.ActorCell.create(ActorCell.scala:578)
remote:         ... 7 more
remote:        Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
remote:         at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
remote:         at akka.contrib.process.BlockingProcess.<init>(BlockingProcess.scala:55)
remote:         ... 16 more
remote:        Caused by: java.io.IOException: error=2, No such file or directory
remote:         at java.lang.UNIXProcess.forkAndExec(Native Method)
remote:         at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
remote:         at java.lang.ProcessImpl.start(ProcessImpl.java:134)
remote:         at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
remote:         ... 17 more
remote:
remote:        [ERROR] [08/11/2022 14:30:33.203] [sbt-web-akka.actor.default-dispatcher-8] [akka://sbt-web/user/$c/process] null
remote:        akka.actor.ActorInitializationException: exception during creation
remote:         at akka.actor.ActorInitializationException$.apply(Actor.scala:166)
remote:         at akka.actor.ActorCell.create(ActorCell.scala:596)
remote:         at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:456)
remote:         at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
remote:         at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:263)
remote:         at akka.dispatch.Mailbox.run(Mailbox.scala:219)
remote:         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
remote:         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
remote:         at java.lang.Thread.run(Thread.java:750)
remote:        Caused by: java.lang.reflect.InvocationTargetException
remote:         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
remote:         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
remote:         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
remote:         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
remote:         at akka.util.Reflect$.instantiate(Reflect.scala:66)
remote:         at akka.actor.ArgsReflectConstructor.produce(Props.scala:355)
remote:         at akka.actor.Props.newActor(Props.scala:255)
remote:         at akka.actor.ActorCell.newActor(ActorCell.scala:552)
remote:         at akka.actor.ActorCell.create(ActorCell.scala:578)
remote:         ... 7 more
remote:        Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
remote:         at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
remote:         at akka.contrib.process.BlockingProcess.<init>(BlockingProcess.scala:55)
remote:         ... 16 more
remote:        Caused by: java.io.IOException: error=2, No such file or directory
remote:         at java.lang.UNIXProcess.forkAndExec(Native Method)
remote:         at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
remote:         at java.lang.ProcessImpl.start(ProcessImpl.java:134)
remote:         at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
remote:         ... 17 more
remote:
remote:        [info] Compiling 74 Scala sources to /tmp/scala_buildpack_build_dir/client/target/scala-2.12/classes...
remote:        [info] Full optimizing /tmp/scala_buildpack_build_dir/client/target/scala-2.12/client-opt.js
remote:        [info] Closure: 0 error(s), 0 warning(s)

It seems to me that Heroku is not able to find Node?

I have both heroku/scala and heroku/nodejs in my buildpack. I'm not that experienced with Scala and I've searched far and wide, but haven't been able to find a solution. Do you have any guesses as to what might be wrong?

Edit 1: When running heroku buildpacks, I get the following output:

1. heroku/scala
2. heroku/nodejs

CodePudding user response:

Buildpacks run in the order they are configured. If your Scala build process requires node, the Node.js buildpack needs to appear before the Scala buildpack.

Also:

The buildpack for the primary language of your app should always be the last buildpack in the list. This ensures that defaults for that primary language are applied instead of those for another language, and allows Heroku to correctly detect the primary language of your app.

One way to change the order of your buildpacks is to clear them, then add them back:

heroku buildpacks:clear
heroku buildpacks:set heroku/scala
heroku buildpacks:add --index 1 heroku/nodejs

You should now find that the Node.js buildpack comes first and the Scala buildpack comes last. If you redeploy, you should find that the Scala build is able to find node.

  • Related