Why "could not find implicit" error in Scala + Intellij + ScalaTest + Scalactic but not from sbt

Workarounds at the bottom of the response. ;)

This problem is related with this list of BUGs:

  • SCL-8167
  • SCL-11083
  • SCL-8396
  • SCL-10912

The problem is that there are dependencies in the project that are using, using test scope, other versions of scalatest and scalactic.

IntelliJ Idea is mixing compile scope and test scope, but SBT is working correctly. IntelliJ Idea team said in the BUG that they are working in this.

My workaround, at the moment, has been move to the same older version that the other libraries are using for testing.

Notes:

@justin-kaeser is assigned and working to fix this. Thx!

A lot of improvement related to the Scala plugin in that latest previews.

Example to reproduce the error : https://github.com/angelcervera/idea-dependencies-bug

Few Workarounds:

  1. Remove problematic dependencies from the Project structure -> Modules
  2. Exclude libraries in the sbt.
  3. Use the same version.
  4. Try with the last EAP: https://www.jetbrains.com/idea/nextversion/

It's possible some dependencies are transitively including incompatible versions of Scalactic or Scalatest in the compile scope, which also are included in the test scope.

You can check this in the Project Structure under Project Settings / Modules / Dependencies tab, and analyze it more closely with the sbt-dependency-graph plugin.

SBT does however perform dependency evictions which IntelliJ does not (issue), which can cause additional problems when compiling from the IDE. If sbt-dependency-graph shows that the conflicting versions are evicted, then it is probably an instance of this issue.

Workaround: when you find the offending transitive dependency, exclude it from the root dependency in your build.sbt. For example:

"org.apache.spark" %% "spark-core" % "2.1.0" % "provided" exclude("org.scalatest", "scalatest_2.11")

Not sure if this was an IDE bug, but for me upgrading the IDE to latest didn't proved to be of any help. After wasting few hours here is my approach to resolve this error. Which states following.

could not find implicit value for parameter prettifier: org.scalactic.Prettifier

Solution :

In IntelliJ press Ctrl+Alt+Shift+S -> Modules -> Dependencies -> Search for 
org.scalactic:3.0.0.jar (Test scope) and most probably there would be 
another version as 2.x.x in compile scope. Right click on 2.x.x and select 
EDIT and then choose the 3.0.0 version in compile scope, and apply new 
settings.

P.S. Depending on your case there may be only one entry but make sure you 
use 3.0.0 in compile scope to get rid of that weird error.