Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear sbt cache?

Tags:

scala

sbt

I'm using sbt 1.3.9 and I need to update some libraries that have changed its code but the version stays the same. When I tried to run sbt update command nothing happened the library not downloaded. I have sbt.build file that looks like the following:

name := """project name"""
organization := "com.example"

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)
lazy val usr = sys.env("MVN_USER")

scalaVersion := "2.13.1"
javacOptions ++= Seq("-source", "11", "-target", "11")
resolvers ++= Seq(
  "Jfrog Artifacts".at("https://artifactory.jfrog.com/")
)
credentials += Credentials(
  ...
)
updateOptions := updateOptions.value.withCachedResolution(false)
updateOptions := updateOptions.value.withLatestSnapshots(false)
libraryDependencies ++= Seq(
  guice,
  javaWs,
  ehcache,
  "com.google.api-client" % "google-api-client" % "1.30.7",
  "org.apache.commons" % "commons-lang3" % "3.9",
  "redis.clients" % "jedis" % "3.2.0"
)

how can I clear sbt cache?

like image 371
John Avatar asked May 12 '26 16:05

John


2 Answers

You can just delete the v1 folder.

The default cache location is platform-dependent:

  • on Linux, ~/.cache/coursier/v1. This also applies to Linux-based CI environments, and FreeBSD too.
  • on OS X, ~/Library/Caches/Coursier/v1.
  • on Windows, %LOCALAPPDATA%\Coursier\Cache\v1, which, for user Alex, typically corresponds to C:\Users\Alex\AppData\Local\Coursier\Cache\v1.
like image 64
mike Avatar answered May 16 '26 20:05

mike


I assuming that you are developing something locally and doing publishLocal - normal repository wouldn't let you override published dependency and snapshots are not cached (sbt checks if newer appeared every time you need to build sth).

In such case start using snapshot versions for the future and/or go to ~/.ivy2/your.organisation/library_scalaVersion and remove whole directory with "bad" version. If library is fetched by Maven (with sbt, unlikely these days) it the same idea but with ~/.m2.

like image 43
Mateusz Kubuszok Avatar answered May 16 '26 18:05

Mateusz Kubuszok



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!