3

I wanted to find out how to set the sbt and Ivy cache directories.

I found on web some conflicting answers so wanted to check here.

sbt -Dsbt.boot.directory=/home/user/.sbt/boot/
sbt -Dsbt.ivy.home=/home/user/.sbt/.ivy2/

Can these be set as environment vars or do they need to be in each build.sbt?

If they're environment vars, would they be sbt.boot.directory and sbt.ivy.home?

Is it better to set them in each build.sbt and possibly also as environment variables?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
mono-dr
  • 217
  • 1
  • 2
  • 9
  • Possible duplicate of [How to configure Ivy cache directory per-user or system-wide?](https://stackoverflow.com/questions/3142856/how-to-configure-ivy-cache-directory-per-user-or-system-wide) – tilde Sep 10 '18 at 20:24

1 Answers1

0

You don't need to set them as sbt launcher will know their values already.

Can these be set as environment vars or do they need to be in each build.sbt?

If you'd like to change them, they should become part of the command line to start the sbt launcher - they're Java's system properties and are set as other Java properties. They are not build settings. There's even no easy way to set them in build.sbt.

If they're environment vars, would they be sbt.boot.directory and sbt.ivy.home?

No. They are not environment variables.

There's nothing really specific to sbt about setting the Java system properties - just think about sbt as a Java application that happens to read the system properties and defaults when they're not.

If you're new to sbt, you'd be better off forgetting about the Java system properties for now. You just need to remember that sbt's global configuration directory is ~/.sbt while ~/.ivy2/ is for Ivy stuff. That's enough to get going with sbt.

Is it better to set them in each build.sbt and possibly also as environment variables?

Given that you cannot set them in build.sbt (it'd be too late in the process of setting up a build from sbt launching process' perspective) and they are no environment variables, the question in the current form has no sensible answer (perhaps a simple "No, it is not" could make sense at all).

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420