bloop icon indicating copy to clipboard operation
bloop copied to clipboard

Unexpected `MissingRequirementError` with bloop console

Open yannick-cw opened this issue 4 years ago • 12 comments

Hey, any idea what is going wrong here? I can reproduce it with running: sbt new scala/scala-seed.g8 and then bloop console root --verbose --version in this fresh project. Starting ammonite standalone works fine. Is that some misconfiguration of my machine or can you reproduce it?

[D] Loading workspace settings from bloop.settings.json
bloop v1.4.0-RC1-105-118a551b

Using Scala v2.12.8 and Zinc v1.3.0-M4+32-b1accb96
Running on Java JDK v11.0.6 (/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home)
  -> Supports debugging user code, Java Debug Interface (JDI) is available.
Maintained by the Scala Center (Jorge Vicente Cantero, Martin Duhem)
[D] Computing sources and classpath hashes for root
[D] Scheduling compilation for root...
[D] Using successful result for root associated with /Users/yannick/otherworkspace/test/.bloop/root/bloop-internal-classes/classes-bloop-cli-_OovRxS0R--EzjuHe5x6LQ==
[D] Cache hit true for plugin /Users/yannick/Library/Caches/bloop/semanticdb/org.scalameta.semanticdb-scalac_2.13.1.4.3.6/semanticdb-scalac_2.13.1-4.3.6.jar
[D] External classes directory /Users/yannick/otherworkspace/test/.bloop/root/bloop-bsp-clients-classes/classes-bloop-cli
[D] Read-only classes directory /Users/yannick/otherworkspace/test/.bloop/root/bloop-internal-classes/classes-bloop-cli-_OovRxS0R--EzjuHe5x6LQ==
[D] New rw classes directory /Users/yannick/otherworkspace/test/.bloop/root/bloop-internal-classes/classes-bloop-cli-SJW4FuyCQ2uMwlzJ7t__iw==
[D] No changes
[D] Recording new last successful request for root associated with /Users/yannick/otherworkspace/test/.bloop/root/bloop-internal-classes/classes-bloop-cli-_OovRxS0R--EzjuHe5x6
LQ==
[D] Skipping delete of /Users/yannick/otherworkspace/test/.bloop/root/bloop-internal-classes/classes-bloop-cli-_OovRxS0R--EzjuHe5x6LQ== associated with no-op result
[D] Wrote Ammonite command to /var/folders/bb/8n4dgm5x1wxgc5ldq_7x61rw0000gn/T/tmpuzo94z
[D] Elapsed: 43.881493 ms
Loading...
Compiling (synthetic)/ammonite/predef/interpBridge.sc
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:286)
  scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:286)
  scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1585)
  scala.tools.nsc.Global$Run.<init>(Global.scala:1205)
  ammonite.interp.Compiler$$anon$1.<init>(Compiler.scala:256)
  ammonite.interp.Compiler$.apply(Compiler.scala:141)
  ammonite.interp.CompilerLifecycleManager.init(CompilerLifecycleManager.scala:98)
  ammonite.interp.CompilerLifecycleManager.preprocess(CompilerLifecycleManager.scala:58)
  ammonite.interp.Interpreter.compileRunBlock$1(Interpreter.scala:491)
  ammonite.interp.Interpreter.$anonfun$processAllScriptBlocks$9(Interpreter.scala:530)
  scala.Option$WithFilter.map(Option.scala:242)
  ammonite.interp.Interpreter.loop$1(Interpreter.scala:516)
  ammonite.interp.Interpreter.processAllScriptBlocks(Interpreter.scala:583)
  ammonite.interp.Interpreter.$anonfun$processModule$6(Interpreter.scala:379)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.interp.Interpreter.$anonfun$processModule$5(Interpreter.scala:370)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.processModule(Interpreter.scala:360)
  ammonite.interp.Interpreter.$anonfun$initializePredef$1(Interpreter.scala:126)
  ammonite.interp.Interpreter.$anonfun$initializePredef$1$adapted(Interpreter.scala:126)
  ammonite.interp.PredefInitialization$.$anonfun$apply$7(PredefInitialization.scala:75)
  ammonite.util.Res$.$anonfun$fold$1(Res.scala:32)
  scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:169)
  scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:165)
  scala.collection.immutable.List.foldLeft(List.scala:79)
  ammonite.util.Res$.fold(Res.scala:30)
  ammonite.interp.PredefInitialization$.apply(PredefInitialization.scala:63)
  ammonite.interp.Interpreter.initializePredef(Interpreter.scala:128)
  ammonite.repl.Repl.initializePredef(Repl.scala:142)
  ammonite.Main.run(Main.scala:212)
  ammonite.MainRunner.$anonfun$runRepl$1(Main.scala:408)
  ammonite.MainRunner.watchLoop(Main.scala:389)
  ammonite.MainRunner.runRepl(Main.scala:408)
  ammonite.Main$.main0(Main.scala:307)
  ammonite.Main$.main(Main.scala:271)
  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:566)
  coursier.cli.launch.Launch$.$anonfun$launch$6(Launch.scala:116)
  coursier.cli.launch.Launch$.$anonfun$task$28(Launch.scala:295)
  coursier.cli.launch.Launch$.run(Launch.scala:356)
  coursier.cli.Coursier$.$anonfun$runA$2(Coursier.scala:79)
  coursier.cli.Coursier$.$anonfun$runA$2$adapted(Coursier.scala:67)
  coursier.cli.CommandAppPreA.run(CommandAppPreA.scala:22)
  caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$5(CommandAppWithPreCommand.scala:98)
  caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$5$adapted(CommandAppWithPreCommand.scala:98)
  scala.util.Either.fold(Either.scala:191)
  caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$3(CommandAppWithPreCommand.scala:98)
  caseapp.core.app.CommandAppWithPreCommand.$anonfun$main$3$adapted(CommandAppWithPreCommand.scala:84)
  scala.Option.foreach(Option.scala:274)
  caseapp.core.app.CommandAppWithPreCommand.main(CommandAppWithPreCommand.scala:84)
  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:566)
  coursier.bootstrap.launcher.a.a(Unknown Source)
  coursier.bootstrap.launcher.Launcher.main(Unknown Source)

yannick-cw avatar Apr 01 '20 07:04 yannick-cw

Oh I also tried with java 9, same problem for me

yannick-cw avatar Apr 01 '20 07:04 yannick-cw

I tried on a fresh installed mac, the same error happens

yannick-cw avatar Apr 02 '20 09:04 yannick-cw

This still happens on bloop v1.4.0-RC1 (Using Scala v2.12.8 and Zinc v1.3.0-M4+32-b1accb96)

As far as I can tell, this only happens when using JDK >8. ~~It might be an outdated ammonite.~~ The latest release is always used, so this isn't the problem.

slice avatar May 08 '20 10:05 slice

Okay, I did more investigation and it looks like you can get it to work like this:

$ bloop console <project> --out-file sample_command
$ sed -i -e 's/coursier/cs/' sample_command
$ sed -i -e 's/--scala-version 2.13.2//' sample_command
$ sh sample_command

This runs using system Coursier (assuming it's installed). It seems like the Coursier bloop is using is too outdated. Also, the --scala-version flag needs to be removed for whatever reason.

For comparison, my local cs is Coursier 2.0.0-RC6-15 while blp-coursier is Coursier 2.0.0-RC3-4. If you make sample_command use blp-coursier then it won't work even if you remove the --scala-version flag.

slice avatar May 08 '20 10:05 slice

Is this related to https://github.com/scalacenter/bloop/issues/1301? Did that change get reverted?

fooblahblah avatar Nov 30 '20 22:11 fooblahblah

The change didn't get reverted. Are you having the same problem still? I am not exactly sure what was happening originally, but I can try to help.

tgodzik avatar Dec 03 '20 19:12 tgodzik

From what I checked this might be an issue with missing jars on classpath, updating coursier should help as I did have the same problem with an older version, but it worked after updating.

tgodzik avatar Dec 03 '20 19:12 tgodzik

@tgodzik I'll try updating coursier. Thanks. Just to reply to your previous comment I'm seeing the same error as the OP.

fooblahblah avatar Dec 03 '20 19:12 fooblahblah

@tgodzik I'll try updating coursier. Thanks. Just to reply to your previous comment I'm seeing the same error as the OP.

Not sure if Bloop is not using an internal version of coursier, I wasn't really able to find it right now. I haven't been able to run Bloop console yet.

tgodzik avatar Dec 03 '20 19:12 tgodzik

I'm running the latest coursier (2.0.7) and Java 11. I tried running Ammonite directly via coursier and it's still borked. So maybe this more of an Ammonite issue? This command is the same one I was using to test https://github.com/scalacenter/bloop/issues/1301, but removing the --scala-version flag has no effect.

$ coursier --version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 -Duser.timezone=UTC
2.0.7

$ java -version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 -Duser.timezone=UTC
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+0-adhoc..source)
OpenJDK 64-Bit Server VM (build 11.0.9+0-adhoc..source, mixed mode)

$ coursier launch com.lihaoyi:ammonite_2.13.3:latest.release --main-class ammonite.Main
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 -Duser.timezone=UTC
Loading...
Compiling /home/jsimpson/.ammonite/predef.sc
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.<init>(Global.scala:1214)
  ammonite.interp.Compiler$$anon$1.<init>(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.compileRunBlock$1(Interpreter.scala:511)
  ammonite.interp.Interpreter.$anonfun$processAllScriptBlocks$15(Interpreter.scala:572)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.$anonfun$processAllScriptBlocks$14(Interpreter.scala:569)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.$anonfun$processAllScriptBlocks$12(Interpreter.scala:566)
  scala.Option.getOrElse(Option.scala:201)
  ammonite.interp.Interpreter.loop$1(Interpreter.scala:566)
  ammonite.interp.Interpreter.processAllScriptBlocks(Interpreter.scala:604)
  ammonite.interp.Interpreter.$anonfun$processModule$6(Interpreter.scala:399)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.interp.Interpreter.$anonfun$processModule$5(Interpreter.scala:390)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.processModule(Interpreter.scala:380)
  ammonite.interp.Interpreter.$anonfun$initializePredef$3(Interpreter.scala:139)
  ammonite.interp.Interpreter.$anonfun$initializePredef$3$adapted(Interpreter.scala:139)
  ammonite.interp.PredefInitialization$.$anonfun$apply$2(PredefInitialization.scala:79)
  ammonite.util.Res$.$anonfun$fold$1(Res.scala:32)
  scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:168)
  scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:164)
  scala.collection.immutable.List.foldLeft(List.scala:79)
  ammonite.util.Res$.fold(Res.scala:30)
  ammonite.interp.PredefInitialization$.apply(PredefInitialization.scala:67)
  ammonite.interp.Interpreter.initializePredef(Interpreter.scala:141)
  ammonite.repl.Repl.initializePredef(Repl.scala:142)
  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)

fooblahblah avatar Dec 07 '20 16:12 fooblahblah

Opened on Feb 24 https://github.com/lihaoyi/Ammonite/issues/1035

fooblahblah avatar Dec 07 '20 16:12 fooblahblah

Hmm... This might be it, I tested it all again and it doesn't work again. I might have had JDK 8 by mistake since I was switching back and forth a lot. I checked what classpath is loaded and i all seems correct:

> coursier resolve com.lihaoyi:ammonite_2.13.3:2.3.8     
ch.epfl.scala:bsp4j:2.0.0-M6:default
com.github.javaparser:javaparser-core:3.2.5:default
com.google.code.gson:gson:2.8.2:default
com.google.guava:guava:21.0:default
com.google.protobuf:protobuf-java:3.11.4:default
com.lihaoyi:ammonite-interp-api_2.13.3:2.3.8:default
com.lihaoyi:ammonite-interp_2.13.3:2.3.8:default
com.lihaoyi:ammonite-ops_2.13:2.3.8:default
com.lihaoyi:ammonite-repl-api_2.13.3:2.3.8:default
com.lihaoyi:ammonite-repl_2.13.3:2.3.8:default
com.lihaoyi:ammonite-runtime_2.13.3:2.3.8:default
com.lihaoyi:ammonite-terminal_2.13:2.3.8:default
com.lihaoyi:ammonite-util_2.13:2.3.8:default
com.lihaoyi:ammonite_2.13.3:2.3.8:default
com.lihaoyi:fansi_2.13:0.2.9:default
com.lihaoyi:fastparse_2.13:2.3.0:default
com.lihaoyi:geny_2.13:0.6.2:default
com.lihaoyi:mainargs_2.13:0.1.4:default
com.lihaoyi:os-lib_2.13:0.7.1:default
com.lihaoyi:pprint_2.13:0.5.9:default
com.lihaoyi:requests_2.13:0.6.5:default
com.lihaoyi:scalaparse_2.13:2.3.0:default
com.lihaoyi:sourcecode_2.13:0.2.1:default
com.lihaoyi:ujson_2.13:1.2.0:default
com.lihaoyi:upack_2.13:1.2.0:default
com.lihaoyi:upickle-core_2.13:1.2.0:default
com.lihaoyi:upickle-implicits_2.13:1.2.0:default
com.lihaoyi:upickle_2.13:1.2.0:default
com.thesamet.scalapb:lenses_2.13:0.10.3:default
com.thesamet.scalapb:scalapb-runtime_2.13:0.10.3:default
io.get-coursier:interface:0.0.21:default
net.java.dev.jna:jna:5.3.1:default
org.eclipse.lsp4j:org.eclipse.lsp4j.generator:0.8.1:default
org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.8.1:default
org.eclipse.xtend:org.eclipse.xtend.lib:2.18.0:default
org.eclipse.xtend:org.eclipse.xtend.lib.macro:2.18.0:default
org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.18.0:default
org.javassist:javassist:3.21.0-GA:default
org.jline:jline:3.15.0:default
org.jline:jline-reader:3.14.1:default
org.jline:jline-terminal:3.14.1:default
org.jline:jline-terminal-jna:3.14.1:default
org.scala-lang:scala-compiler:2.13.3:default
org.scala-lang:scala-library:2.13.3:default
org.scala-lang:scala-reflect:2.13.3:default
org.scala-lang.modules:scala-collection-compat_2.13:2.1.6:default
org.scala-lang.modules:scala-xml_2.13:1.2.0:default
org.scalameta:common_2.13:4.3.20:default
org.scalameta:fastparse-utils_2.13:1.0.1:default
org.scalameta:fastparse_2.13:1.0.1:default
org.scalameta:trees_2.13:4.3.20:default

tgodzik avatar Dec 07 '20 17:12 tgodzik