com-lihaoyi / Ammonite

Scala Scripting
http://ammonite.io
MIT License
2.61k stars 369 forks source link

Ammonite caches dependencies too aggressively #874

Open betehess opened 6 years ago

betehess commented 6 years ago

I am trying to get an Ammonite script to depend on the latest version of an internal dependency.

I have something that looks like that:

interp.repositories() = List(coursier.MavenRepository("..."), ...)
System.setProperty("coursier.ttl", "0s")
interp.load.ivy("foo.bar" %% "baz" % sys.env.getOrElse("VERSION", "0+"))

@

@main def entrypoint(args: String*): Unit = {
  foo.bar.baz.Main.main(args.toArray)
}

It looks like Ammonite is not able to detect that a new version was released. We currently ask the users of the script to either:

But it defeats the purpose of having users not to worry about knowing what the latest version is.

The coursier.ttl trick was suggested by @alexarchambault and he pointed me to https://github.com/coursier/coursier/blob/a2ef75abcbb2cbdbc421f22c55a4a2ab960687e2/cache/jvm/src/main/scala/coursier/Cache.scala#L1137 but it didn't fix the problem.

alexarchambault commented 6 years ago

This is kind of the same issue as https://github.com/lihaoyi/Ammonite/issues/433 (whose fix was lost at some point, it seems).

I guess we can get rid of the ivyCache of Ammonite altogether… It's not that useful since the switch to coursier, and it can have unintended side effects, like this issue.