coursier / coursier

Pure Scala Artifact Fetching
https://get-coursier.io
Apache License 2.0
2.04k stars 309 forks source link

necessary dependency not present in classpath on launch #2764

Open jpassaro opened 1 year ago

jpassaro commented 1 year ago
$ coursier launch org.scalameta:metals_2.13:0.11.12 -M scala.meta.metals.DownloadDependencies
Exception in thread "main" java.lang.NoClassDefFoundError: scribe/LoggerSupport
    at scala.meta.metals.DownloadDependencies$.main(DownloadDependencies.scala:32)
    at scala.meta.metals.DownloadDependencies.main(DownloadDependencies.scala)
Caused by: java.lang.ClassNotFoundException: scribe.LoggerSupport
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 2 more
$ coursier resolve org.scalameta:metals_2.13:0.11.12 | grep scribe
com.outr:scribe-file_2.13:3.11.1:default
com.outr:scribe-slf4j_2.13:3.11.1:default
com.outr:scribe_2.13:3.11.1:default
$ unzip -l /Users/jpassaro/coursier-cache/https/repo1.maven.org/maven2/com/outr/scribe_2.13/3.11.1/scribe_2.13-3.11.1.jar | grep LoggerSupport
warning [/Users/jpassaro/coursier-cache/https/repo1.maven.org/maven2/com/outr/scribe_2.13/3.11.1/scribe_2.13-3.11.1.jar]:  147456 extra bytes at beginning or within zipfile
  (attempting to process anyway)
     6401  01-01-2010 00:00   scribe/LoggerSupport$.class
    10387  01-01-2010 00:00   scribe/LoggerSupport.class
$ coursier version
2.1.3

To summarize: it seems like coursier knows that scribe is a dependency for the metals artifact, and the scribe jar includes this class, but when running the metals artifact the scribe class doesn't seem to be on the classpath.

adpi2 commented 1 year ago

I could not reproduce this bug:

$ coursier version
2.1.3
$ coursier launch org.scalameta:metals_2.13:0.11.12 -M scala.meta.metals.DownloadDependencies
2023.05.21 10:21:36 INFO  Downloading mdoc
...

It is hard to guess what's going wrong here. Could you share the output of coursier fetch org.scalameta:metals_2.13:0.11.12 | grep scribe ? Also what is your java -version ?