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

mill _.repl fails if module depends on mainargs #3000

Closed
KireinaHoro opened this issue Feb 3, 2024 · 1 comment
Closed

mill _.repl fails if module depends on mainargs #3000

KireinaHoro opened this issue Feb 3, 2024 · 1 comment
Milestone

Comments

@KireinaHoro
Copy link

It seems like _.repl fails to launch when the module depends on mainargs as well. Reproducible case:

import mill._
import mill.util._
import scalalib._

object mymod extends ScalaModule {
  def scalaVersion = "2.13.12"
  override def ivyDeps = Agg(
    ivy"com.lihaoyi::mainargs:0.5.4"
  )
}

Output:

-> % mill mymod.repl
No mill version specified.
You should provide a version via '.mill-version' file or --mill-version option.
Using mill version 0.11.6
[build.sc] [49/53] compile
[info] compiling 1 Scala source to /tmp/out/mill-build/compile.dest/classes ...
[info] done compiling
[46/46] mymod.repl
Exception in thread "main" java.lang.NoClassDefFoundError: mainargs/ArgReader
        at ammonite.AmmoniteMain$.main0(AmmoniteMain.scala:51)
        at ammonite.AmmoniteMain$.main(AmmoniteMain.scala:31)
        at ammonite.AmmoniteMain.main(AmmoniteMain.scala)
Caused by: java.lang.ClassNotFoundException: mainargs.ArgReader
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
        ... 3 more
1 targets failed
mymod.repl java.lang.Exception: Interactive Subprocess Failed (exit code 1)
    mill.util.Jvm$.runSubprocess(Jvm.scala:184)
    mill.util.Jvm$.runSubprocessWithBackgroundOutputs(Jvm.scala:152)
    mill.util.Jvm$.runSubprocess(Jvm.scala:88)
    mill.scalalib.ScalaModule.$anonfun$repl$2(ScalaModule.scala:441)
    scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
    scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
    scala.Console$.withErr(Console.scala:193)
    mill.api.SystemStreams$.$anonfun$withStreams$2(SystemStreams.scala:62)
    scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
    scala.Console$.withOut(Console.scala:164)
    mill.api.SystemStreams$.$anonfun$withStreams$1(SystemStreams.scala:61)
    scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
    scala.Console$.withIn(Console.scala:227)
    mill.api.SystemStreams$.withStreams(SystemStreams.scala:60)
    mill.scalalib.ScalaModule.$anonfun$repl$1(ScalaModule.scala:448)
    mill.define.Task$TraverseCtx.evaluate(Task.scala:71)
@lefou
Copy link
Member

lefou commented Feb 19, 2024

This concrete issue is likely fixed, since we updated mainargs to it's latest version in PR #3019.

But this does not fix the general issue completely. One aspect is the version pinning we could improve (we already working towards that), the other aspect is that there is always a slight chance the repl will fail, when your local project / classpath has conflicting dependencies with the repl itself. A workaround in such situations can be to use the alternative console, which might have less features, but also less dependencies.

@lefou lefou closed this as completed Feb 19, 2024
@lefou lefou added this to the 0.11.8 milestone Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants