Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL: load transitive dependencies of JARs on classpath #6660

scabug opened this issue Nov 13, 2012 · 4 comments

REPL: load transitive dependencies of JARs on classpath #6660

scabug opened this issue Nov 13, 2012 · 4 comments


Copy link

scabug commented Nov 13, 2012

The Scala REPL should load dependencies referenced in MANIFEST.MF files of other JARs on the classpath.

As described in

We have JAR files that contain standard META-INF/MANIFEST.MF files with the Class-Path: entry. This entry points to a number of other JARs that should be loaded transitively by the ClassLoader. Unfortunately the REPL does not load these transitive dependencies, instead dependency JARs need to be placed on the classpath explicitly one by one.

As an example let's say I have A.jar and B.jar. I also have a C.jar that has nothing else in it than a MANIFEST.MF with 'Class-Path: A.jar B.jar'. If I use

> scala -classpath A.jar;B.jar

everything is ok. I can e.g import A and import B. However, if I use

> scala -classpath C.jar

I couldn't import or use any classes from A.jar or B.jar.
Copy link

scabug commented Nov 13, 2012

Imported From:
Reporter: @szeiger
Affected Versions: 2.10.0

Copy link

scabug commented Apr 19, 2015

Li Haoyi (lihaoyi) said:
This works in the Ammonite REPL, not with raw jar files, but you can specify any coordinate on maven central and the REPL will pull down any transitive dependencies necessary. e.g. here I am asking for upickle and getting jawn-parser for free:

@ load.ivy("com.lihaoyi" %% "upickle" % "0.2.6")
:: resolving dependencies :: com.lihaoyi#upickle_2.11-caller;working
	confs: [default]
	found com.lihaoyi#upickle_2.11;0.2.6 in central
	found org.scala-lang#scala-library;2.11.4 in central
	[2.11.4] org.scala-lang#scala-library;2.11.4
	found org.spire-math#jawn-parser_2.11;0.7.0 in central
	found com.lihaoyi#acyclic_2.11;0.1.2 in central
	found org.scala-lang#scala-compiler;2.11.0 in central
	found org.scala-lang.modules#scala-xml_2.11;1.0.1 in central
	found org.scala-lang.modules#scala-parser-combinators_2.11;1.0.1 in central
	found org.scala-lang#scala-reflect;2.11.4 in central
	[2.11.4] org.scala-lang#scala-reflect;2.11.4
res17: Unit = ()
@ import upickle._
import upickle._
@ upickle.write(Seq(1, 2, 3))
res19: String = "[1,2,3]"

Copy link

SethTisue commented Nov 21, 2019

I wonder how the Dotty REPL does on this

Copy link

lrytz commented Nov 22, 2019

From outside the repl, it can be done with coursier (dwijnand/scala-runners#3), so there's some overlap here with the work discussed at scala/scala-dev#326.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

No branches or pull requests

4 participants