Sbt error Some keys were defined with the same name but different types

I did a git push from home, and a git pull from work. The main (I believe) that changed was a line was added to my build.sbt file.

40
IntelliJ notified me that I need to “Import Changes”. When I clicked “Import” I got the following error.

IntelliJ has an option to “Invalidate caches and restart…”. I tried that, but I still get the same error when I try to “Import Changes” again.

I’m appreciate any suggestion about how to figure out what’s happening, and how to fix it?

Error while importing sbt project:

[info] Loading settings for project global-plugins from idea.sbt,plugins.sbt ...
[info] Loading global plugins from /Users/jnewton/.sbt/1.0/plugins
[info] Loading project definition from /Users/jnewton/scalain_e/scalain-e-course-code/project
[info] Loading settings for project scalain-e-course-code from build.sbt ...
[info] Set current project to scalain-e-course-code (in build file:/Users/jnewton/scalain_e/scalain-e-course-code/)
[info] sbt server started at local:///Users/jnewton/.sbt/1.0/server/952a20c74ae1365594d3/sock
sbt:scalain-e-course-code>
[info] Defining Global / sbtStructureOptions, Global / sbtStructureOutputFile and 1 others.
[info] The new values will be used by Global / dumpStructure, Global / ssOptions, cleanKeepFiles
[info] 	Run `last` for details.
[info] Reapplying settings...
[info] Set current project to scalain-e-course-code (in build file:/Users/jnewton/scalain_e/scalain-e-course-code/)
[info] Applying State transformations org.jetbrains.sbt.CreateTasks from /Users/jnewton/Library/Application Support/IdeaIC2019.1/Scala/repo/org.jetbrains/sbt-structure-extractor/scala_2.12/sbt_1.0/2018.2.1+4-88400d3f/jars/sbt-structure-extractor.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]]), 'ssExtractBuilds' (sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.BuildData]], sbt.Task[scala.collection.Seq[org.jetbrains.sbt.structure.BuildData]]), '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:26)
[error] 	at sbt.internal.Index$.stringToKeyMap0(EvaluateConfigurations.scala:368)
[error] 	at sbt.internal.Index$.stringToKeyMap(EvaluateConfigurations.scala:355)
[error] 	at sbt.internal.Load$.structureIndex(Load.scala:335)
[error] 	at sbt.internal.Load$.reapply(Load.scala:350)
[error] 	at sbt.BuiltinCommands$.reapply(Main.scala:475)
[error] 	at org.jetbrains.sbt.CreateTasks$.reapply(CreateTasks.scala:65)
[error] 	at org.jetbrains.sbt.CreateTasks$.applySettings(CreateTasks.scala:56)
[error] 	at org.jetbrains.sbt.CreateTasks$.apply(CreateTasks.scala:47)
[error] 	at org.jetbrains.sbt.CreateTasks$.apply(CreateTasks.scala:11)
[error] 	at sbt.BasicCommands$.$anonfun$call$6(BasicCommands.scala:234)
...

There was some discussion here about a similar problem. One person suggested to completely re-install IntelliJ. Someone else made an easier suggestion.

The suggestion was to change the preferences to “Use sbt shell [for imports] and [for builds]”.
I initially had both these check-boxes as FALSE. I changed them to TRUE, as per the suggestion.

This seems to have magically fixed the problem.

1 Like