I have just updated the IDE, plugin version and library dependencies, and now I can\'t build my project. SBT throws java.lang.NoClassDefFoundError: sbt/TrackLevel
w
That can happen for various reasons, usually because of some mismatched versions or leftover caches. Surprisingly often, sbt can't gracefully handle updating plugins, let alone itself and it's the reason I waste hours every time I decide to refresh my project and bump up versions.
You know, just in case. Pay attention to the plugin/dependency you've just updated and whether anything is mentioned in its changelog. Keep this in mind while going through the Attempt 1.
This is a good chance to update all (other) dependencies and plugins (of course, if that doesn't break your project but it shouldn't be the case unless you're already using deprecated methods). Doing so might resolve the issue, so look up library dependencies you're referencing in your build.sbt
, plugins from project/plugins.sbt
and sbt version itself in project/build.properties
and bring them up to their latest versions (consult Google and appropriate repositories, e.g. http://mvnrepository.com).
If you're still using activator
or play
commands to build your project, grab the Java/Scala seed or one of the templates from Play donwload page, extract and copy sbt (if you intend building it on Linux), sbt.bat (if you intend running it on Windows) and sbt-dist directory into your project and feel free to delete any references to activator from your project. Try executing ./sbt
and see if it works.
Since you're still reading this, chances are updating dependencies didn't really do the job. Well, at least now you have a refreshed project.
Remove target/
. Remove project/target/
. Remove project/project/target/
. Curse whomever came up with those cache names and their paths. (Protip: holding shift while hitting delete will skip the recycle bin and delete the files permanently.) Attempt to built the project again and hope everything is okay now.
In case it didn't do the job, as a last resort we're gonna remove all the caches and start fresh. Repeat step 2 in case previous failed build left something behind.
Navigate to your home folder. Remove .ivy
and/or .ivy2
. Remove .sbt
, or in case it contains some configuration you want to retain rename it to e.g. .sbt.old
and restore specific files afterwards. It could take a while since those directories could contain dozens of thousands of files. (You could delete all IDE caches here, but I've never encountered that being the issue - it will rebuild the whole project on next launch anyway since you've destroyed most of which it relies on already)
Go back to your project folder and rerun ./sbt
. That could take a few minutes since it will download all dependencies (including sbt and Play themselves) and put them in place. After that, you will have fresh project, as if you've build it from source on a clean machine.
In case it still doesn't work, you can safely assume it's either mistake in your build files (triple check them again) or a bug in the build system.