scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.08k stars 325 forks source link

Bloop error when switching between minor versions of Scala 3 due to dirty cached compiler output directory #5955

Open smarter opened 9 months ago

smarter commented 9 months ago

Describe the bug

(I'm not sure if this is a bloop issue or a metals issue, but the path to the dirty cache includes "Metals" so it might be under metals' control). I switched from a nightly of Scala 3.4 to Scala 3.3 in a project and metals reported a bloop error due to a tasty file compiled with Scala 3.4 being read by the Scala 3.3 compiler:

error id: YOTzVt81VQLDdHD9WU0ZMg==
### Bloop error:

error while loading BdlInterface,
class file <WORKSPACE>/.bloop/prj_forj_main/bloop-internal-classes/classes-Metals-0ge9W8bwRqii2JtoiW_wuw==-N20lSK8mSyKOyALtcAt50w==/com/arteris/forj/BdlInterface.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
 expected: {majorVersion: 28, minorVersion: 3}
 found   : {majorVersion: 28, minorVersion: 4 [unstable release: 1]}

This TASTy file was produced by an unstable release.
To read this TASTy file, your tooling must be at the same version.
The TASTy file was produced by Scala 3.4.0-RC1-bin-20231207-16f1680-NIGHTLY-git-16f1680.
#### Short summary: 

error while loading BdlInterface,
class file <WORKSPACE>/.bloop/prj_forj_main/bloop-internal-classes...

Expected behavior

Metals/Bloop should clear the compiler output directory they use when switching between compiler versions to ensure this does not happen.

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

v1.2.0

Extra context or search terms

No response

tgodzik commented 9 months ago

Thanks for reporting! This is an issue with Bloop, I need to investigate.