Bloop: Missing Scala library jar in Maven project

Created on 27 Aug 2019  路  4Comments  路  Source: scalacenter/bloop

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:

  1. Clone https://github.com/dcmn-com/herringbone.git
  2. switch to upgrade-scala-2.12 branch
  3. install thrift locally (apt-get install or brew)
  4. run mvn install -DskipTests see https://github.com/scalameta/metals/issues/882
  5. import build with Metals in any text editor
  6. Notice error in logs

Using 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:

  • Operating system: Linux
  • Editor: Sublime
  • Metals version: 0.7.0+111-0039eb7c-SNAPSHOT
  • Bloop version: v1.3.2
  • Java 8
bug help wanted integrations maven

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.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.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olafurpg picture olafurpg  路  8Comments

jvican picture jvican  路  3Comments

Arthurm1 picture Arthurm1  路  6Comments

propensive picture propensive  路  3Comments

jatcwang picture jatcwang  路  4Comments