简体   繁体   English

Heroku Scala 应用程序部署失败:无法运行程序“节点”

[英]Heroku deployment of Scala app fails with: Cannot run program "node"

I'm trying to deploy a Scala/Play app to Heroku using sbt, but I keep getting the following error:我正在尝试使用 sbt 将 Scala/Play 应用程序部署到 Heroku,但我不断收到以下错误:

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?在我看来,Heroku 无法找到节点?

I have both heroku/scala and heroku/nodejs in my buildpack.我的 buildpack 中有 heroku/scala 和 heroku/nodejs。 I'm not that experienced with Scala and I've searched far and wide, but haven't been able to find a solution.我对 Scala 没有那么有经验,我已经进行了广泛的搜索,但找不到解决方案。 Do you have any guesses as to what might be wrong?您对可能出现的问题有任何猜测吗?

Edit 1: When running heroku buildpacks , I get the following output:编辑1:运行heroku buildpacks时,我得到以下 output:

1. heroku/scala
2. heroku/nodejs

Buildpacks run in the order they are configured. Buildpacks 按照配置的顺序运行。 If your Scala build process requires node , the Node.js buildpack needs to appear before the Scala buildpack.如果您的 Scala 构建过程需要node ,则 Node.js 构建包需要出现在 Scala 构建包之前。

Also : 还有

The buildpack for the primary language of your app should always be the last buildpack in the list.应用程序主要语言的 buildpack 应该始终是列表中的最后一个buildpack。 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.这可确保应用该主要语言的默认值而不是其他语言的默认值,并允许 Heroku 正确检测应用程序的主要语言。

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.您现在应该会发现 Node.js buildpack 排在第一位,Scala buildpack 排在最后。 If you redeploy, you should find that the Scala build is able to find node .如果重新部署,您应该会发现 Scala 构建能够找到node

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM