Bloop fails to compile a maven workspace with multi project. Instead I get this error
metals: error while loading Object, Missing dependency 'object scala.native in compiler mirror', required by /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar(java/lang/Object.class)
metals: time: compiled herringbone-impala in 1.57s
metals: Unexpected error when compiling herringbone-impala: 'object scala in compiler mirror not found.'
metals: Failed to compile 'herringbone-impala','herringbone-main'
step to reproduce:
https://github.com/dcmn-com/herringbone.git upgrade-scala-2.12 branchapt-get install or brew)mvn install -DskipTests see https://github.com/scalameta/metals/issues/882Using bloop CLI also leads to the same error:
bloop compile herringbone-impala ->
Compiling herringbone-impala (5 Scala sources)
Compiled herringbone-impala (43ms)
[E] Unexpected error when compiling herringbone-impala: 'object scala in compiler mirror not found.'
[E] Failed to compile 'herringbone-impala'
Installation:
Hi @ayoub-benali Thank you for writing this ticket and finding a reproduction for this bug. We will try to look into it as soon as we can! :smile:
I have similar issue in vscode + metals. At first time, it completes import build successfully with a scala compiler project. However, when I boot vscode at second time, go to definition does not work(probably, all functions related to bloop is gone) and reimport build fails with below error messages.
error while loading Object, Missing dependency 'class scala.native in compiler mirror', required by /home/soya/opt/jdk1.8.0_221/jre/lib/rt.jar(java/lang/Object.class)
time: compiled library in 5.85s
Unexpected error when compiling library: 'class scala.annotation.StaticAnnotation in compiler mirror not found.'
Failed to compile 'library', 'reflect' and 1 more projects
A simple project that does not have subproject does not occur this problem.
Environment
uname -a:
Linux soya 5.0.0-27-generic #28~18.04.1-Ubuntu SMP Thu Aug 22 03:00:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
java -version:
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
editor: vscode version1.38
metals version: 0.7.5
bloop version: automatically installed by metals
I'm marking this as "help wanted" because I cannot personally look into it any time soon. I would appreciate if somebody can have a look at this error.
I've had a closer look at what's happening here. The Bloop plugin for Maven doesn't seem to be adding the scala library jar in the classpath field. However, the scala.jars section of the configuration file does indeed have a reference to all of the relevant scala jars (library, reflect, compiler, etc): https://gist.github.com/jvican/074499727a125d17c445d8c4fa2c9492
Adding the Scala library jar to the classpath makes the compilation work.
@ayoub-benali Are you interested in taking a look at how to fix this? I'm happy to provide pointers to find the offending issue and make Bloop work with your Maven project. Realistically nobody will have time to look at this otherwise.
Most helpful comment
I've had a closer look at what's happening here. The Bloop plugin for Maven doesn't seem to be adding the scala library jar in the classpath field. However, the
scala.jarssection of the configuration file does indeed have a reference to all of the relevant scala jars (library, reflect, compiler, etc): https://gist.github.com/jvican/074499727a125d17c445d8c4fa2c9492Adding the Scala library jar to the classpath makes the compilation work.
@ayoub-benali Are you interested in taking a look at how to fix this? I'm happy to provide pointers to find the offending issue and make Bloop work with your Maven project. Realistically nobody will have time to look at this otherwise.