coursier / coursier/coursier

Launching ammonite causes scala.reflect.internal.MissingRequirementError on Java != 8

Open
#1,925 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
2.1k
Forks
334
Avg merge
1d 16h
Merged PRs (30d)
69

Description

Not sure if this belongs here or in ammonite or maybe even nixpkgs, but let me try:

I have the problem, that I can only launch ammonite via coursier with Java 8. 11 and 14 result in this error:

```
$ coursier launch com.lihaoyi:ammonite_2.13.3:2.3.8 -M ammonite.Main
Loading...
Welcome to the Ammonite Repl 2.3.8 (Scala 2.13.3 Java 14.0.2-internal)
@ // press RETURN or any expression whatsoever
scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:24)
scala.reflect.internal.Mirrors$RootsBase.$anonfun$getModuleOrClass$6(Mirrors.scala:66)
scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:56)
scala.reflect.internal.Mirrors$RootsBase.getRequiredClass(Mirrors.scala:56)
scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:287)
scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:287)
scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1608)
scala.tools.nsc.Global$Run.(Global.scala:1214)
ammonite.interp.Compiler$$anon$1.(Compiler.scala:274)
ammonite.interp.Compiler$.apply(Compiler.scala:142)
ammonite.interp.CompilerLifecycleManager.init(CompilerLifecycleManager.scala:89)
ammonite.interp.CompilerLifecycleManager.preprocess(CompilerLifecycleManager.scala:57)
ammonite.interp.Interpreter.$anonfun$processLine$4(Interpreter.scala:251)
ammonite.util.Res$Success.flatMap(Res.scala:62)
ammonite.interp.Interpreter.$anonfun$processLine$2(Interpreter.scala:244)
ammonite.util.Catching.flatMap(Res.scala:115)
ammonite.interp.Interpreter.processLine(Interpreter.scala:243)
ammonite.repl.Repl.$anonfun$action$8(Repl.scala:197)
ammonite.util.Res$Success.flatMap(Res.scala:62)
ammonite.repl.Repl.$anonfun$action$4(Repl.scala:184)
ammonite.repl.Scoped.$anonfun$flatMap$1(Signaller.scala:45)
ammonite.repl.Signaller.apply(Signaller.scala:28)
ammonite.repl.Scoped.flatMap(Signaller.scala:45)
ammonite.repl.Scoped.flatMap$(Signaller.scala:45)
ammonite.repl.Signaller.flatMap(Signaller.scala:16)
ammonite.repl.Repl.$anonfun$action$2(Repl.scala:176)
ammonite.util.Catching.flatMap(Res.scala:115)
ammonite.repl.Repl.action(Repl.scala:168)
ammonite.repl.Repl.loop$1(Repl.scala:208)
ammonite.repl.Repl.run(Repl.scala:223)
ammonite.Main.$anonfun$run$1(Main.scala:223)
scala.Option.getOrElse(Option.scala:201)
ammonite.Main.run(Main.scala:211)
ammonite.MainRunner.$anonfun$runRepl$1(Main.scala:415)
ammonite.MainRunner.watchLoop(Main.scala:396)
ammonite.MainRunner.runRepl(Main.scala:415)
ammonite.Main$.main0(Main.scala:321)
ammonite.Main$.main(Main.scala:270)
ammonite.Main.main(Main.scala)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:564)
coursier.cli.launch.Launch$.$anonfun$launch$6(Launch.scala:180)
coursier.cli.launch.Launch$.$anonfun$launchCall$13(Launch.scala:354)
coursier.cli.launch.Launch$.run(Launch.scala:540)
coursier.cli.Coursier$.$anonfun$runA$2(Coursier.scala:157)
coursier.cli.Coursier$.$anonfun$runA$2$adapted(Coursier.scala:139)
coursier.cli.CommandAppPreA.run(CommandAppPreA.scala:22)
caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$5(CommandAppWithPreCommand.scala:99)
caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$5$adapted(CommandAppWithPreCommand.scala:99)
scala.util.Either.fold(Either.scala:191)
caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$3(CommandAppWithPreCommand.scala:99)
caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$3$adapted(CommandAppWithPreCommand.scala:85)
scala.Option.foreach(Option.scala:407)
caseapp.core.app.CommandAppWithPreCommand.main(CommandAppWithPreCommand.scala:85)
coursier.cli.Coursier$.main(Coursier.scala:104)
coursier.cli.Coursier.main(Coursier.scala)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:564)
coursier.bootstrap.launcher.a.a(Unknown Source)
coursier.bootstrap.launcher.Launcher.main(Unknown Source)

```
This probably has something to do with the fact that I am on NixOS, but the issue is also reproducible via this docker image

```
FROM nixos/nix

RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
RUN nix-channel --update

RUN nix-env -iA nixpkgs.ncurses
RUN nix-env -iA nixpkgs.coursier
```

with

```
docker build . -t repro
docker run -it repro coursier launch com.lihaoyi:ammonite_2.13.3:2.3.8 -M ammonite.Main
```

As ammonite works as expected with other Java versions when running outside of coursier, I think it must be some interaction between coursier, ammonite and the way nix works or how [coursier is packaged in nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/coursier/default.nix) (which looks inconspicuous as far as I can tell, though). Running e.g. scalafmt via `coursier launch` in the above manner does not exhibit the same behaviour.

Unfortunately I apparently am not competent enough to get to the bottom of this myself. Has anyone else seen this happen? I initially stumbled upon this because `bloop console ` (which in turn calls roughly the above command + adding the project classpath) has the same problem.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.