Karl
Karl

Reputation: 1244

sbt 1.3.8 publishLocal creates a jar that sbt update can't resolve. scala version is appended to jar name

I published some libraries using sbt publishLocal it worked and published to my ~/.ivy2/local dir.

I then have a project that depends on these libraries but sbt update can't find them.

specifically, my project has these dependencies:

lazy val myDependencies = commonDependencies ++ Seq(
    "my.corp"  %% "lib1" % "1.0.1-SNAPSHOT" withSources () withJavadoc (),
    "my.corp"  %% "lib2" % "2.0.2-SNAPSHOT" withSources () withJavadoc ()
  )

sbt update has this error:

[error] (services / update) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] file:////home/myuser/.ivy2//local/my.corp/lib1_2.12/1.0.1-SNAPSHOT/jars/lib1.jar: not found: /home/myuser/.ivy2//local/my.corp/lib1_2.12/1.0.1-SNAPSHOT/jars/lib1.jar
[error] file://///home/myuser/.ivy2//local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars/lib2.jar: not found: /home/myuser/.ivy2//local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars/lib2.jar

when I look in the dir I can see the published jars but their name has the scala version appended, which is why the update resolving fails, I think :

$ ls /home/myuser/.ivy2/local/my.corp/lib1_2.12/1.0.1-SNAPSHOT/jars
lib1_2.12.jar  lib1_2.12.jar.md5  lib1_2.12.jar.sha1

$ ls /home/myuser/.ivy2/local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars
lib2_2.12.jar  lib2_2.12.jar.md5  lib2_2.12.jar.sha1

If I publish to a repo for real I can resolve the libs.

Does anyone know the sbt incantation to fix this? ;-)

Cheers Karl

Update:- I think coursier is the problem, not sure how to tell it to look for lib2_2_12.jar. Could it have a bad cached reference?

Caused by: lmcoursier.internal.shaded.coursier.cache.ArtifactError$NotFound: not found: /home/myuser/.ivy2/local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars/lib2.jar

Update:- disabling coursier worked from the sbt REPL I can run

sbt:my-project> set ThisBuild / useCoursier := false

and then

sbt:my-project> update

and that worked, but setting it back to true update failed again, so this looks like a coursier issue.

Update: coursier fetch from the command line worked!!

coursier fetch my.corp::lib1:1.0.1-SNAPSHOT --no-default -r central -r ivy2Local

downloaded the transitive dependencies and found my jar in my local ivy2 dir

so this is back to looking like an sbt - coursier interaction issue

Upvotes: 4

Views: 1016

Answers (1)

joelsk
joelsk

Reputation: 11

I've just now run into this and after lots of diffs between an older working version and this non-working version I figured out that it is the withSources() that triggers the bug in sbt and/or coursier.

Upvotes: 1

Related Questions