3

I am learning Scala and downloaded IntelliJ Idea. I installed the Scala plugin and was instantly given the 2.12 version. Now I am trying to downgrade to 2.11 because I need this version to follow along a Coursera class I am taking.

I am having the same "UNRESOLVED DEPENDENCIES" shown in the link below: SBT project refresh failed [IntelliJ, Scala, SBT]

I tried to solve my problem by doing what @Haspemulator suggested, but I'm still getting error messages. Here is a screenshot of what I have now:

enter image description here

(Notice that there is a folder called scala-2.12)

4
  • 1
    I solved the problem I was having with line 6 and 7 in the picture above. I first ran lines 1-5. Once those were done, I ran line 7.
    – pandasCat
    Commented Dec 28, 2016 at 22:34
  • 1
    Also in line 7 should say: libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % Test Updated question: What Scala version am I using for this project? Am I using 2.11.8 or 2.12?
    – pandasCat
    Commented Dec 28, 2016 at 22:41
  • make sure you are using all the dependencies for scala 2.11 and not 2.12. mvnrepository.com/artifact/org.scalatest/scalatest_2.11/3.0.0 Commented Dec 29, 2016 at 9:14
  • The scala-2.12 folder doesn't matter. It was likely created automatically before you added scalaVersion and not deleted afterwards. Just don't forget to reimport your project if you didn't set import automatically when creating it. Commented Dec 29, 2016 at 12:53

2 Answers 2

1

The error you get states that "Cannot add dependency ... to configuration "Test" because this configuration doesn't exist!" There's no such predefined configuration as "Test". There's only "test" (lower case). Try to use it instead.

2
  • 1
    Thank you. Yes that was one of my problems. My main question now is: Is it necessary to downgrade from Scala 2.12 to 2.11.8 or does the line scalaVersion := "2.11.8" let me switch to the older Scala version in this project?
    – pandasCat
    Commented Dec 28, 2016 at 22:45
  • 3
    scalaVersion should do it, and the %% on line 7 means you get the 2.11 version of scalatest too.
    – HTNW
    Commented Dec 29, 2016 at 1:43
1

CatherineAlv has already solved the problem. I am just segregating the steps together.

I too faced this problem while setting up scala for coursera course "Functional Programming Principles in Scala". By default build.sbt was showing scalaVersion as 2.12.x but I needed 2.11.x for the course. This can be easily solved in two steps:

  1. Change the scalaVersion in build.sbt. The code would look like after change:

     name := "Example"
     version := "1.0"
     scalaVersion := "2.11.8"
    

    Build it.

  2. Add the libraryDependencies to build.sbt. The code would now look like this:

     name := "Example"
     version := "1.0"
     scalaVersion := "2.11.8"
     libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.6" % "test"
    

    Build again.

This should solve it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.