Scala-3.3.0: dotty.tools.FatalError: 无法解析引用至

huangapple go评论122阅读模式
英文:

Scala-3.3.0: dotty.tools.FatalError: cannot resolve reference to

问题

我在scala-3.3.0和akka(或pekko)中遇到了这个错误:

dotty.tools.FatalError: 无法解析对类型 akka.stream.scaladsl.type.Source 的引用
dotty.tools.FatalError: 无法解析对类型 org.apache.pekko.stream.scaladsl.type.Source 的引用

在这两种情况下,我在任何源代码或依赖项中都找不到这样的引用。

为了演示这个问题,我创建了一个小的GitHub存储库:
https://github.com/abrighton/scala3-test

主分支使用pekko,而“akka-version”分支使用akka。
两者都使用java-17和scala-3.3.0。

我找到的可能相关的最接近的问题是:
https://github.com/lampepfl/dotty/pull/16373

有什么想法是什么可能导致这个问题的原因吗?

英文:

I'm seeing this error with scala-3.3.0 and akka (or pekko):

dotty.tools.FatalError: cannot resolve reference to type akka.stream.scaladsl.type.Source
dotty.tools.FatalError: cannot resolve reference to type org.apache.pekko.stream.scaladsl.type.Source

In both cases I see no such reference in any of the sources or dependencies.

To demonstrate the problem, I created a small GitHub repo:
https://github.com/abrighton/scala3-test

The main branch uses pekko and the "akka-version" branch uses akka.
Both use java-17 and scala-3.3.0.

The closest issue I could find that might be related was:
https://github.com/lampepfl/dotty/pull/16373

Any ideas what could be causing this?

答案1

得分: 1

你正在使用pekko-http作为依赖。

> Pekko HTTP模块在pekko-actorpekko-stream之上实现了完整的服务器和客户端HTTP堆栈。

这意味着您还需要在类路径中添加依赖项pekko-actorpekko-stream

只需添加

libraryDependencies += "org.apache.pekko" %% "pekko-stream" % PekkoVersion

应该可以解决您的问题。


附带说明:

不确定文档是否不完整,或者pekko-http的Hello World示例是否难以找到。查看Pekko模块pekko-stream未列出。我找不到g8模板或类似的内容。

仅根据您分享的错误消息

dotty.tools.FatalError: 无法解析到类型 akka.stream.scaladsl.type.Source
dotty.tools.FatalError: 无法解析到类型 org.apache.pekko.stream.scaladsl.type.Source

并且知道Source来自stream模块,我采取了一个猜测,添加了pekko-stream依赖项,编译成功。


编辑:

找到一个pekko http quickstart模板。

英文:

You are using pekko-http as a dependency

> The Pekko HTTP modules implement a full server- and client-side HTTP stack on top of pekko-actor and pekko-stream.

Which means you need to have also the dependencies pekko-actor and pekko-stream added in the classpath.

Just adding

libraryDependencies += "org.apache.pekko" %% "pekko-stream" % PekkoVersion

should fix your problem.


Side Note:

Not sure if the docs are incomplete or a hello world for pekko-http is hard to find. Checking the Pekko Modules, pekko-stream is not listed. I couldn't find g8 template or something similar.

Just based on the error message you shared

dotty.tools.FatalError: cannot resolve reference to type akka.stream.scaladsl.type.Source
dotty.tools.FatalError: cannot resolve reference to type org.apache.pekko.stream.scaladsl.type.Source

And knowing that Source comes from the stream module, I took a wild guess and added the pekko-stream dependency and the compilation succeed.


EDIT:

found a pekko http quickstart template

huangapple
  • 本文由 发表于 2023年8月5日 05:30:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839190.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定