Search code examples
scalamavenjvmsbtpublish

Failed to resolve ivy dependencies: Error downloading com.github.jupyter:jvm-repr:0.4.0


I am learning about SBT compiling and publishing rules. Consider the following example project I set up:

My build.sbt file looks like:

name := "example"

version := "0.1"

scalaVersion := "2.13.2"

// almond jupyter api
resolvers += "jvm-repr" at "https://maven.imagej.net/content/repositories/public/"
libraryDependencies += "com.github.jupyter" % "jvm-repr" % "0.4.0"
libraryDependencies += "sh.almond" %% "jupyter-api" % "0.9.1"

My Example.scala file looks like:

import almond.interpreter.api.{DisplayData, OutputHandler}

object Example extends App {
    def f1() = {
      DisplayData(
        Map(
          // if we set up an extension for application/myapp+json, first element should be picked
          "application/myapp+json" -> """{"a": "A"}""",
          // else, text/html should be displayed
          "text/html" -> "<b>A</b>"
        )
      )
    }

    println(f1())
}

Now in the sbt shell I type:

compile; run

The output I get:

DisplayData(Map(application/myapp+json -> {"a": "A"}, text/html -> A),Map(),None)

All well and good as it's working as expected.

Now I publish this package locally. In sbt shell I type:

publishLocal

I get a message that this has been published to

.ivy2./local/default/example_2.13/0.1

All well and good.

Now I start up an almond.sh kernel to see if I can successfully import my package and use it. But...

I have the following error:

enter image description here

Why is this happening? The package seemed to compile and build, yet when I publish it it fails. So somehow the resolvers are not getting added to the published package. Could someone please explain to me what is going on and how to fix it?


Solution

  • In almond you are missing repository: "https://maven.imagej.net/content/repositories/public/", which you added in sbt.

    Since almond uses ammonite this should help:

    interp.repositories() ++= Seq(
      coursierapi.MavenRepository
        .of("https://maven.imagej.net/content/repositories/public/")
    )