Ammonite
Ammonite copied to clipboard
Incomplete artifact downloading/unpacking (.so file missing)
I encountered an issue with an artifact containing native libraries. The SQLite4Java project is released under several artifacts:
- the main artifact contains the JAR file (see https://mvnrepository.com/artifact/com.almworks.sqlite4java/sqlite4java)
- then several additional artifacts contains additionnal JARs and native libraries for several platforms. For linux amd64 the artifact is https://mvnrepository.com/artifact/com.almworks.sqlite4java/libsqlite4java-linux-amd64
However when doing and $ivy import from Ammonite the .so files are not fetched/unpacked properly:
import $ivy.`com.almworks.sqlite4java:libsqlite4java-linux-amd64:1.0.392`
This can be checked with the following command suggested by @alexarchambault:
repl.sess.frames.flatMap(_.classpath)
which gives
res2: List[java.net.URL] = List(
file:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/almworks/sqlite4java/sqlite4java/1.0.392/sqlite4java-1.0.392.jar,
file:~/.cache/coursier/v1/https/repo1.maven.org/maven2/com/almworks/sqlite4java/sqlite4java/1.0.392/sqlite4java-1.0.392-sources.jar
)
while
coursier fetch com.almworks.sqlite4java:libsqlite4java-linux-amd64:1.0.392 -A '*'
gives
~/.coursier/cache/v1/https/repo1.maven.org/maven2/com/almworks/sqlite4java/libsqlite4java-linux-amd64/1.0.392/libsqlite4java-linux-amd64-1.0.392.so
~/.coursier/cache/v1/https/repo1.maven.org/maven2/com/almworks/sqlite4java/sqlite4java/1.0.392/sqlite4java-1.0.392.jar
@alexarchambault concluded on gitter that it shows that at least two artifacts should be loaded, a jar and a .so file
@david-bouyssie Are you using a particular Ammonite version? I don't get any JAR with import $ivy.`com.almworks.sqlite4java:libsqlite4java-linux-amd64:1.0.392` , repl.sess.frames.flatMap(_.classpath) stays empty (unlike in you apparently).
@alexarchambault I think it is linked to the fact that I previously did import the main dependency:
$ivy.`com.almworks.sqlite4java:sqlite4java:1.0.392`
However it was not in the same session if I remember correctly. I can do it again if you want to double check.
So with the current nightlies and the upcoming releases (> 1.6.9), so files can be loaded with
interp.resolutionHooks += { fetch =>
fetch.addArtifactTypes("so")
}
(ran in a cell prior to the one doing import $ivy).
Also, doing import $ivy.`com.almworks.sqlite4java:libsqlite4java-linux-amd64:1.0.392` should also bring sqlite4java-1.0.392.jar, once a new release of coursier has been cut (> 2.0.0-RC2-6), and is used in Ammonite.
@alexarchambault great! Does this is also work similarly for .dll files on windows?
Does this is also work similarly for .dll files on windows?
It should, yes.