2

I’m writing an ammonite script to work with Github4s library to access the github api and have a issue, probably with the classpath. The simple version of the script is as follows:

import $ivy.`com.47deg::github4s:0.17.0`, github4s.Github, github4s.Github._, github4s.jvm.Implicits._, scalaj.http.HttpResponse

val listCommits = Github().repos.listCommits("lihaoyi", "ammonite")

listCommits.exec[cats.Id, HttpResponse[String]]() match {
  case Left(e) => println(s"Something went wrong: ${e.getMessage}")
  case Right(r) => r.result.foreach { commit => println(s"${commit.sha}: 
    ${commit.message.take(35)}") }
}

It's pretty much copied from the github4s tutorial and it fails with:

java.lang.AbstractMethodError
  jawn.CharBasedParser.parseString(CharBasedParser.scala:90)
  jawn.CharBasedParser.parseString$(CharBasedParser.scala:87)
  jawn.StringParser.parseString(StringParser.scala:15)
  jawn.Parser.rparse(Parser.scala:428)
  jawn.Parser.parse(Parser.scala:337)
  jawn.SyncParser.parse(SyncParser.scala:24)
  jawn.SupportParser.$anonfun$parseFromString$1(SupportParser.scala:15)
  jawn.SupportParser.parseFromString(SupportParser.scala:15)
  jawn.SupportParser.parseFromString$(SupportParser.scala:14)
  io.circe.jawn.CirceSupportParser$.parseFromString(CirceSupportParser.scala:7)
  io.circe.jawn.JawnParser.parse(JawnParser.scala:16)
  io.circe.parser.package$.parse(package.scala:8)
  io.circe.Parser.decode(Parser.scala:26)
  io.circe.Parser.decode$(Parser.scala:25)
  io.circe.parser.package$.decode(package.scala:5)
  github4s.HttpRequestBuilderExtensionJVM.decodeEntity(HttpRequestBuilderExtensionJVM.scala:89)
  github4s.HttpRequestBuilderExtensionJVM.decodeEntity$(HttpRequestBuilderExtensionJVM.scala:88)
  github4s.jvm.Implicits$.decodeEntity(Implicits.scala:21)

Exactly the the same code works in a simple SBT project that makes me think Ammonite injects something in the classpath and it breaks github4s.

Is there a way to have a cleaner classpath in ammonite scripts or how else can I go around this issue?

makados
  • 149
  • 1
  • 3
  • 11
  • The problem here is `jawn-parser`. github4s `0.16.0` requires circe (with cats 1.0) that requires jawn-parser 0.11.0. sbt 1.0 requires jawn-parser 0.10.4 and there is a binary incompatibility in between jawn-parser 0.10.4 and 0.11.0. – Fede Nov 16 '17 at 17:18

1 Answers1

1

I had the same problem as you. Here, what I figured:

Ammonite 1.0.3 does indeed use (indirectly) jaws 0.10.4 (by upickle). However, unstable version of Ammonite is already migrated to newer version of upickle, with in turns use jaws 0.11.

So with Ammonite unstable I was able to run my problem without running into AbstractMethodError issue.

Mateusz Kubuszok
  • 24,995
  • 4
  • 42
  • 64