首页 文章

IntelliJ中的Scala编译错误:找不到输出目录

提问于
浏览
0

IntelliJ IDEA(最新的社区版本)无法编译带有错误的dotty编译器:

scala.reflect.internal.FatalError: Could not find an output directory for
/src/contrib/dotty/scala-backend/src/compiler/scala/tools/nsc/backend/ScalaPrimitivesOps.scala
in List(
(/src/contrib/dotty/compiler/test-resources,/src/contrib/dotty/compiler/target/scala-2.12/classes),
(/src/contrib/dotty/compiler/target/scala-2.12/resource_managed/main,/src/contrib/dotty/compiler/target/scala-2.12/classes),
(/src/contrib/dotty/compiler/target/scala-2.12/src_managed/main,/src/contrib/dotty/compiler/target/scala-2.12/classes),
(/src/contrib/dotty/compiler/test,/src/contrib/dotty/compiler/target/scala-2.12/classes),
(/src/contrib/dotty/compiler/src,/src/contrib/dotty/compiler/target/scala-2.12/classes))

显然,代码没有任何问题,Dotty似乎可以使用sbt进行编译,因为 run 命令可以正常工作 . Is there something special that needs to be done for an sbt project to make IDEA compile using sbt? 是否导致此错误?否则,这个错误意味着什么?

To Reproduce

  • 删除先前安装中的任何设置后,使用新安装的IntelliJ IDEA .

  • 使用 git clone --recursive https://github.com/lampepfl/dotty 下载存储库

  • 确保安装了最新版本的 sbt . 从项目的根目录运行 sbt managedSources .

  • 使用带有Oracle JDK 1.8的 sbt 类型的 Import project from external model 设置导入IntelliJ . 否则保持默认值 .

  • 右键单击项目资源管理器中的项目,然后选择 Load/Unload Modules... . 卸载除 dottydotty-compilerdotty-librarydotty-interfaces 之外的所有模块 . (http://dotty.epfl.ch/docs/contributing/intellij-idea.html中列出的模块)

  • 在项目资源管理器中,单击 compiler . 从 Build 菜单中单击 Build Module 'dotty-compiler' .

What does not fix it

它没有修复任何事情 File => Invalidate Caches/Restart .

它没有修复任何东西以保持所有模块加载 .

2 回答

  • 2

    根据我的经验,这种错误的一个原因是你在shell中打开输出文件夹或类似的东西 . 看起来有时IDEA会尝试删除整个文件夹,如果由于使用该文件夹而无法执行此操作,则会神秘地导致此类错误 .

  • 1

    您可以尝试使用内置的sbt shell来编译sbt项目:

    enter image description here

相关问题