Using the Cats library for Scala in IntelliJ IDEA leads to errors even if terminal SBT works. Can we fix this? Or some workaround that isn't switching editor?
In most cases your project JDK is not compatible with Scala or sbt version, try to change the Scala Compile Server SDK. Press Ctrl+Alt+S to open Settings/Preferences dialog. From the options on the left, select Build, Execution, Deployment | Compiler | Scala | Scala Compiler Server.
Cats seems to work fine on my IntelliJ 2018.1.4. If it is working in the terminal but not in IntelliJ, it could be because of using in-built IntelliJ compiler. Have you tried enabling Use sbt shell for build and import
, which delegates building to SBT:
View | Tool Windows | sbt
sbt settings
iconUse sbt shell for build and import (required sbt 0.13.5+)
Use sbt shell
might resolve compilation issues, however note that in-editor error highlighting might still give false positives because it uses custom-built typechecker.
Metals is an alternative that uses Scala proper for both compilation and in-editor error diagnostics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With