ACO
ACO

Reputation: 295

How to force sbt to redownload dependencies when ivy cache corrupted

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?

Upvotes: 23

Views: 51141

Answers (4)

user12372096
user12372096

Reputation: 46

In case someone uses coursier, try this:

rm -rf ~/.cache/coursier

and then reload or restart sbt and try it again.

Upvotes: 0

Tony Fraser
Tony Fraser

Reputation: 757

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.

Upvotes: 38

Santi
Santi

Reputation: 1812

Try removing the specific dependency that is causing the problem:

rm -rf ~/.ivy2/cache/commons-codec

Upvotes: 3

Yordan Georgiev
Yordan Georgiev

Reputation: 5440

  # 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

Upvotes: 6

Related Questions