when ivy cache is corrupted I got the following error from sbt
[error] unresolved dependency: commons-codec#commons-codec;1.10: configuration not found in commons-codec#commons-codec; 1.10: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe.play#play_2.11;2.4.3 compile
if I delete the folder commons-codec in ivy cache and run sbt update, sbt will re-download the dependencies and everything will be fine.
Is there a way to tell sbt to delete the folder and re-download dependencies automatically?
Clearing the Ivy cache The Ivy cache can become corrupted, especially when using the http type in the repositories section of conf/dependencies. yml . If this happens, and dependency resolution does not work, you can clear the cache with the --clearcache option. This is equivalent to rm -r ~/.
All new SBT versions (after 0.7. x ) by default put the downloaded JARS into the . ivy2 directory in your home directory. If you are using Linux, this is usually /home/<username>/.
update resolves dependencies according to the settings in a build file, such as libraryDependencies and resolvers . Other tasks use the output of update (an UpdateReport ) to form various classpaths. Tasks that in turn use these classpaths, such as compile or run , thus indirectly depend on update .
It's pretty easy, just
rm -fr ~/.ivy2/cache # Or mv ~/.ivy2/cache ~/.ivy2/cache_bk
sbt update
Finally if you are in Intellij, File -> Invalidate Caches / Restart.
I just did the same thing 20 minutes ago. Probably not a bad thing either. I just saved a pretty big chunk of space on my mac.
Atom:~ me$ du -skh ./.iv*
349M ./.ivy2
1.0G ./.ivy2_bak
[Added 6-May-2021]
If you remove ~/.ivy2 and all your stuff still assembles, cleans, tests, etc. without re-downloading, you might be using another tool, like sdkman, that puts cached files in a different place. Wipe that cache like so.
pwd
~/Library/Caches/Coursier/v1/https/repo1.maven.org
mv ./maven2/ ./_maven2-backup
As a word of caution, it is probably best backup your cache files rather than just wiping them. There are cases, like internally developed bad packages, that you might need to copy over from the backup to the new download. Back it up, rebuild your project, then rm -fr the backup.
# empty the ivy cache if you have good network
# rm -rfv ~/.ivy2/cache/*
# or even better just backup it to sync it later on ...
# mv ~/.ivy2/cache ~/.ivy2/cache.`date "+%Y%m%d_%H%M%S`.bak
# remove all sbt lock files
find ~/.sbt ~/.ivy2 -name "*.lock" -print -delete
find ~/.sbt ~/.ivy2 -name "ivydata-*.properties" -print -delete
# remove all the class files
rm -fvr ~/.sbt/1.0/plugins/target
rm -fvr ~/.sbt/1.0/plugins/project/target
rm -fvr ~/.sbt/1.0/target
rm -fvr ~/.sbt/0.13/plugins/target
rm -fvr ~/.sbt/0.13/plugins/project/target
rm -fvr ~/.sbt/0.13/target
rm -fvr ./project/target
rm -fvr ./project/project/target
sbt clean update
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