question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to specify the coursier cache location from the sbt command line?

See original GitHub issue

The code suggests this is possible, but I haven’t been able to make it work. I’ve tried

sbt -Dcoursier.cache=.coursier compile

sbt -Dcoursier.cache=/absolute/path/to/.coursier compile

sbt -Dcoursier.cache=/absolute/path/to/without/period/coursier compile

sbt -Dcoursier.cache="/lets/try/quotation/marks/coursier" compile

But the system always uses ~/.coursier instead.

Setting the coursier cache location via export (as per the README, export COURSIER_CACHE="$(pwd)/.coursier-cache") works as expected. Is there a reason this doesn’t?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
davidmwebercommented, Oct 3, 2019

Coursier uses the COURSIER_CACHE environment variable to specify the cache. So:

export COURSIER_CACHE=some/dir sbt clean compile

4reactions
tarsacommented, Sep 20, 2019

@drewctaylor SBT actually uses different Java system property: -Dsbt.coursier.home. Look here https://github.com/sbt/sbt/blob/v1.3.1/main/src/main/scala/sbt/coursierint/LMCoursier.scala#L40-L44

  def defaultCacheLocation: File =
    sys.props.get("sbt.coursier.home") match {
      case Some(home) => new File(home).getAbsoluteFile / "cache"
      case _          => CoursierDependencyResolution.defaultCacheLocation
    }

-Dcoursier.cache somehow doesn’t have any effect on SBT in my case too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache - Coursier
The cache is used to cache artifacts that don't change often (snapshot artifacts ... When using Coursier with SBT, you can check the...
Read more >
changing coursier cache directory of the bundled sbt
with "C:\Users<user>\AppData\Local\Coursier\cache" being the default coursier cache location. So far, I tried to add the following to the settings > Build ...
Read more >
sbt Reference Manual — Remote Caching
To abstract machine-specific paths such as your working directory and Coursier cache directory, sbt keeps a map of root paths in ThisBuild /...
Read more >
scala - how can I change the coursier cache directory ...
with C:\Users\<user>\AppData\Local\Coursier\cache being the default coursier cache location. So far, I tried to add the following VM Parameters ...
Read more >
coursier/coursier - Gitter
I posted what I want to achieve (pre-cache artifact with all its dependencies in docker ... Is there a way to download a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found