IDEA says a dependency is missing, SBT disagrees

Viewed 213

my issue seems similar to Getting IntelliJ IDEA understand SBT dependencies

except I'm using sbt 1.4.4 ,and the plugin suggested in that question no longer appears to work (it requires sbt version 0.13.x, and last commit to that plugin was 7 years ago)

is there anything similar that might work with more recent versions of sbt, or some other way to get intelliJ to work?

It only seems to affect 2 dependencies, all other dependencies works fine, thing is, i really need those 2 dependencies. I'm on Linux, should it matter, a colleague opened the same code on Mac, and had no issues, however I've tried clearing every cache i could think of, reinstalled IDEA, rebooted twice, changed idea settings to use sbt shell for everything, nothing and everything in between. I've tried to rebuild with sbt version override enabled and/or disabled.

I dont get any errors from intelliJ rebuilding the project, but the editor still insists that some dependencies does not exist!

I'm out of ideas, how can I fix IDEA?

1 Answers

First identify the path to problematic dependencies by executing

sbt 'show dependencyClasspath'

which prints out something like

Attributed(/home/picard/.cache/coursier/v1/https/repo1.maven.org/maven2/org/typelevel/mouse_2.13/1.0.0/mouse_2.13-1.0.0.jar)

Next in the following order

  1. sbt clean the project
  2. invalidate caches
  3. Exit IntelliJ
  4. nuke your project's .idea directory.

Now say mouse was the problematic dependency, then remove it with

rm -fr /home/picard/.cache/coursier/v1/https/repo1.maven.org/maven2/org/typelevel/mouse_2.13

Finally reimport the sbt project which, if you have the shortcut setup, from project's root directory

idea .

and let sbt refetch the missing dependencies and let IntelliJ reindex them.

Related