Surprise: SBT 2 huge caches

I understand the appeal of caching task results. Reusing expensive outputs can make large builds and CI much faster. But making persistent disk caching automatic for all tasks is a pretty startling default for a build tool.

I did not knowingly opt into a second artifact store. I discovered it only after a worktree had accumulated about 53 GiB in sbt’s CAS. Another active worktree had about 11.5 GiB. The blobs were build outputs such as Scala and Scala.js compilation artifacts. Deleting the old worktree recovered a substantial amount of disk space.

The cost is especially odd with multiple worktrees. sbt describes this as a machine-wide cache, but launchers can assign each worktree its own sbt.global.base (and often they need to do this with LLM agents, which need to run sandboxed). On CI you sometimes do not want to use any caches at all, you want to do clean builds. In such setup, equivalent outputs accumulate in separate caches instead of being shared. We are speaking of 10-40 GB per worktree in my case, which can (and did) quickly exhaust available server space with several concurrent worktrees.

Maybe the cache helps other projects a lot; the problem is that users pay the storage cost before they know whether they benefit. An escape hatch such as Global / cacheStores := Nil is not an adequate answer if turning it off requires changing every project’s build, or if a custom launcher bypasses the normal user-level sbt settings.

Please consider:

  • making persistent task-result caching opt-in, or defaulting to a bounded cache;
  • providing a simple user-level opt-out that applies across projects and launchers;
  • exposing cache size, location, age, and eviction controls clearly;
  • document the change more. I have read SBT 2.x changes, but I did not see this described clearly

A cache should make builds faster, not quietly turn every worktree into another potentially huge artifact archive. If sbt believes this should be the default, users should at least get a clear size limit and a simple, reliable way to opt out.