Multiple scala libraies causing error in intellij?

后端 未结 11 1860
独厮守ぢ
独厮守ぢ 2021-02-05 02:23

I am using intellij 14 with scala 2.11.6 installed using home brew and symlink using

ln -s /usr/local/Cellar/scala/2.11.6/libexec/src /usr/local/Cellar/scala/2.1         


        
相关标签:
11条回答
  • 2021-02-05 02:52

    I had the same issue than you experimented and the solution, actually very easy, was actually erasing the .idea folder from the project, the problem is that the configuration inside of this folder (containing the set ups for example for the test, VCS, the runs, etc) gets corrupted with double entries (probably cos you update your Scala version), once you do this and reopen the project in Intellij the IDEA will generate a fresh new configuration for you.

    0 讨论(0)
  • 2021-02-05 02:53

    2019 update... I'm running Ubuntu Linux and IntelliJ community 2019.1 with sbt 2.13.1 and got the exact same error. I also found that if I built directly from sbt with "runMain package.MyClass" it worked, so I knew it must be an IntelliJ problem, not a "real" problem.

    Anyway, I found the file .idea/libraries/sbt.. lots of crazy long name ... scala_library_2_13_1_jar.xml.

    In it, there was an XML block , and in that block, two entries were duplicated: I first noticed the scala-library one, and after deleting that, the error report came up about the scala-compiler duplicate too. After deleting both duplicates, my build is now working.

    0 讨论(0)
  • 2021-02-05 03:01

    Maybe you have used

    /usr/local/Cellar/scala/2.11.6/
    

    as the path for Scala SDK?

    When you install scala with homebrew that path will contain not only the scala libraries, but also a symlink with the relevant libraries for intellij. So if you use the top-level install directory intellij will find the libraries twice.

    Instead you should use

    /usr/local/Cellar/scala/2.11.6/idea/lib
    
    0 讨论(0)
  • 2021-02-05 03:01

    Remove the following line in build.sbt:

    ...
    
    scalaVersion := "2.13.0"
    
    ...
    

    Try rebuilding and running it again

    0 讨论(0)
  • 2021-02-05 03:02

    Delete multiple versions of scala-library in sbt, leaving one.

    0 讨论(0)
  • 2021-02-05 03:03

    To fix the problem go to project structure in intellij and go to global libraries It should be like this

    After that remove all the scala SDKs by hitting the - mark

    Next, click the + and choose your Scala SDK version to add

    After that please make sure to apply the changes and re-run the program

    0 讨论(0)
提交回复
热议问题