motek96
motek96

Reputation: 423

No 'scala-library*.jar' in every new IntelliJ Scala Project

I have installed intelliJ-IDEA 2017.2.5 with scala plugin on Ubuntu 16.04LTS. When I create new scala project and try to run it I get:

Error:scalac: No 'scala-library*.jar' in Scala compiler classpath in Scala SDK SBT: org.scala-lang:scala-library:2.12.4:jar

I can fix it by going to Project Structure > Libraries, deleting libraries and adding them again.

Is there a way to change default library so I don't have to do this every time I create new project?

Upvotes: 40

Views: 19833

Answers (5)

Just upgraded 2017.3.3 to 2017.3.4 on sbt 1.0.3 and Scala 2.12.4. Basically, same s*#t again. In my case it was the warning "Skipping scala files without a scala sdk" for each module after project rebuild.

However, it was only an issue for the sbt project open during the update, whereas the other projects worked fine afterwards. For the broken project, I finally got its checked-out version from git to work (after "invalidate caches" and other hassle.)

So these steps may hopefully save future trouble:

  1. Add the relevant project config files to VC
  2. Commit project
  3. Close project
  4. Upgrade

Upvotes: 0

David M Hildebrandt
David M Hildebrandt

Reputation: 15

Switching from scala 2.12.2 to 2.12.3 fixed this for me.

I too had this problem using IntelliJ 2017.2.4. My build.sbt (originating from the "play-scala-starter-example" project) contained:

scalaVersion := "2.12.2"

I changed this to:

scalaVersion := "2.12.3"

And then completed a 'Refresh project'.

I did this after noticing that when I added the most current Scala SDK: scala-sdk-2.12.3 - (File->Project Structure->Modules, select 'root' and 'Dependencies' tab, then add library), and then I moved it to nearly the first position in the classpath, that I passed SBT: org.scala-lang:scala-library:2.12.2:jar along the way. Being first in the classpath, the "No 'scala-library*.jar' in Scala compiler classpath ..." message disappeared.

Upvotes: 1

Fernando
Fernando

Reputation: 406

In my case upgrading the Scala plugin via IntelliJ options made the trick.

It could be related to a fixed issue.

Go to Preferences, filter on Scala. (Plugins - Scala) click on Update. Restart IntelliJ.

Upvotes: 1

vnd
vnd

Reputation: 322

Select checkbox "Use SBT shell for build and import" in Idea SBT settings. It might help.

Upvotes: 18

CrazyCoder
CrazyCoder

Reputation: 402235

If you are using sbt 1.0.2, this problem might be due to a bug in sbt. A fix is expected for sbt 1.0.3.

Related issues:

Possible workarounds:

  • configure Scala version 2.12.3
  • OR downgrade to sbt 0.13.16

Upvotes: 40

Related Questions