Scala
IntelliJ
sbt

IntelliJでScalaプロジェクトを開いたときに「Some keys were defined with the same name but different types: 'ssExtractBuild'」というエラーが発生

環境

  • IntelliJ IDEA 2018.1(Community Edition)
  • JDK 1.8.0_162
  • Scala 2.12.5
  • SBT 1.1.2

問題

以下のプロジェクトをIntelliJで開いたときに、「Some keys were defined with the same name but different types: 'ssExtractBuild'」というエラーが発生しました。

  • コンソール用のScala プロジェクト
  • mainメソッドがあるだけ
  • .ideaフォルダは存在しない
IntelliJのsbt_shell
Error while importing sbt project:

[info] Loading settings from idea.sbt ...
[info] Loading global plugins from C:\Users\yuji38kwmt\.sbt\1.0\plugins
[info] Loading project definition from C:\Projects\ScalaConsole\project
[info] Loading settings from build.sbt ...
[info] Set current project to SampleTool (in build file:/C:/Projects/ScalaConsole/)
[info] sbt server started at local:sbt-server-69bd30c193b5f89579d6
sbt:SampleTool>
[info] Defining Global / sbtStructureOptions, Global / sbtStructureOutputFile, shellPrompt
[info] The new values will be used by Global / dumpStructure, Global / ssOptions
[info] Reapplying settings...
[info] Set current project to SampleTool (in build file:/C:/Projects/ScalaConsole/)
[info] Applying State transformations org.jetbrains.sbt.CreateTasks from C:/Users/yuji38kwmt/.IdeaIC2018.1/config/plugins/Scala/launcher/sbt-structure-1.0.jar
[info] Reapplying settings...
[error] java.lang.RuntimeException: Some keys were defined with the same name but different types: 'ssExtractBuild' (sbt.Task[org.jetbrains.sbt.structure.BuildData], sbt.Task[org.jetbrains.sbt.structure.BuildData]), 'settingData' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.SettingData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.SettingData]]), 'taskData' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.TaskData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.TaskData]]), 'extractStructure' (sbt.Task[org.jetbrains.sbt.structure.StructureData], sbt.Task[org.jetbrains.sbt.structure.StructureData]), 'ssExtractDependencies' (sbt.Task[org.jetbrains.sbt.structure.DependencyData], sbt.Task[org.jetbrains.sbt.structure.DependencyData]), 'ssExtractProjects' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]]), 'ssExtractAndroid' (sbt.Task[scala.Option[org.jetbrains.sbt.structure.AndroidData]], sbt.Task[scala.Option[org.jetbrains.sbt.structure.AndroidData]]), 'ssExtractRepository' (sbt.Task[scala.Option[org.jetbrains.sbt.structure.RepositoryData]], sbt.Task[scala.Option[org.jetbrains.sbt.structure.RepositoryData]]), 'ssOptions' (org.jetbrains.sbt.Options, org.jetbrains.sbt.Options), 'commandData' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.CommandData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.CommandData]]), 'ssExtractProject' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]]), 'ssExtractPlay2' (sbt.Task[scala.Option[org.jetbrains.sbt.structure.Play2Data]], sbt.Task[scala.Option[org.jetbrains.sbt.structure.Play2Data]])
[error]     at scala.sys.package$.error(package.scala:27)
[error]     at sbt.internal.Index$.stringToKeyMap0(EvaluateConfigurations.scala:271)
[error]     at sbt.internal.Index$.stringToKeyMap(EvaluateConfigurations.scala:262)
[error]     at sbt.internal.Load$.structureIndex(Load.scala:336)
[error]     at sbt.internal.Load$.reapply(Load.scala:352)
[error]     at sbt.BuiltinCommands$.reapply(Main.scala:404)
[error]     at org.jetbrains.sbt.CreateTasks$.reapply(CreateTasks.scala:64)
[error]     at org.jetbrains.sbt.CreateTasks$.applySettings(CreateTasks.scala:55)
[error]     at org.jetbrains.sbt.CreateTasks$.apply(CreateTasks.scala:46)
[error]     at org.jetbrains.sbt.CreateTasks$.apply(CreateTasks.scala:11)
[error]     at sbt.BasicCommands$.$anonfun$call$6(BasicCommands.scala:204)
[error]     at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:122)
[error]     at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:118)
[error]     at scala.collection.immutable.List.foldLeft(List.scala:86)
[error]     at scala.collection.TraversableOnce.$div$colon(TraversableOnce.scala:151)
[error]     at scala.collection.TraversableOnce.$div$colon$(TraversableOnce.scala:151)
[error]     at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:104)
[error]     at sbt.BasicCommands$.$anonfun$call$2(BasicCommands.scala:204)
[error]     at sbt.Command$.$anonfun$applyEffect$4(Command.scala:134)
[error]     at sbt.Command$.$anonfun$applyEffect$2(Command.scala:130)
[error]     at sbt.MainLoop$.processCommand(MainLoop.scala:154)
[error]     at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:137)
[error]     at sbt.State$$anon$1.runCmd$1(State.scala:242)
[error]     at sbt.State$$anon$1.process(State.scala:248)
[error]     at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:137)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]     at sbt.MainLoop$.next(MainLoop.scala:137)
[error]     at sbt.MainLoop$.run(MainLoop.scala:130)
[error]     at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:108)
[error]     at sbt.io.Using.apply(Using.scala:22)
[error]     at sbt.MainLoop$.runWithNewLog(MainLoop.scala:102)
[error]     at sbt.MainLoop$.runAndClearLast(MainLoop.scala:58)
[error]     at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:43)
[error]     at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error]     at sbt.StandardMain$.runManaged(Main.scala:113)
[error]     at sbt.xMain.run(Main.scala:76)
[error]     at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]     at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]     at xsbt.boot.Launch$.run(Launch.scala:109)
[error]     at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]     at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]     at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]     at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error]     at xsbt.boot.Boot$.main(Boot.scala:17)
[error]     at xsbt.boot.Boot.main(Boot.scala)
[error] Some keys were defined with the same name but different types: 'ssExtractBuild' (sbt.Task[org.jetbrains.sbt.structure.BuildData], sbt.Task[org.jetbrains.sbt.structure.BuildData]), 'settingData' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.SettingData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.SettingData]]), 'taskData' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.TaskData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.TaskData]]), 'extractStructure' (sbt.Task[org.jetbrains.sbt.structure.StructureData], sbt.Task[org.jetbrains.sbt.structure.StructureData]), 'ssExtractDependencies' (sbt.Task[org.jetbrains.sbt.structure.DependencyData], sbt.Task[org.jetbrains.sbt.structure.DependencyData]), 'ssExtractProjects' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]]), 'ssExtractAndroid' (sbt.Task[scala.Option[org.jetbrains.sbt.structure.AndroidData]], sbt.Task[scala.Option[org.jetbrains.sbt.structure.AndroidData]]), 'ssExtractRepository' (sbt.Task[scala.Option[org.jetbrains.sbt.structure.RepositoryData]], sbt.Task[scala.Option[org.jetbrains.sbt.structure.RepositoryData]]), 'ssOptions' (org.jetbrains.sbt.Options, org.jetbrains.sbt.Options), 'commandData' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.CommandData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.CommandData]]), 'ssExtractProject' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.ProjectData]]), 'ssExtractPlay2' (sbt.Task[scala.Option[org.jetbrains.sbt.structure.Play2Data]], sbt.Task[scala.Option[org.jetbrains.sbt.structure.Play2Data]])
[error] Use 'last' for the full log.
[info] shutting down server
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0

原因

よくわかりません。

解決方法

C:\Users\yuji38kwmt\.sbt\1.0フォルダを削除してから、再度開いたら問題ありませんでした。

stackoverflowの回答

StackOverFlowには、「"Use SBT shell for build and import"にチェックを入れる」という回答がありました。

https://stackoverflow.com/questions/47084795/strange-sbt-bug-where-i-cannot-import-sbt-project-due-to-keys-colliding-with-the

Go to Preference > Build, Execution, Deployment > SBT > check "Use SBT shell for build and import" > Press OK You can now refresh SBT projects and it should work . if you want, you could uncheck "Use SBT shell for build and import" and it will also work

「requires sbt 0.13.5+」と書いてあるので、チェックを入れた方がいいんですかね?
今はまだよくわからないです。
image.png