Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metals 1.4 fails compilation with Wartremover installed #6889

Closed
andyczerwonka opened this issue Oct 25, 2024 · 23 comments
Closed

Metals 1.4 fails compilation with Wartremover installed #6889

andyczerwonka opened this issue Oct 25, 2024 · 23 comments
Labels
bloop Bloop related tickets fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket
Milestone

Comments

@andyczerwonka
Copy link
Contributor

andyczerwonka commented Oct 25, 2024

Compiler quits with Wartremover Enabled

During today's upgrade from 1.3.5 to 1.4.0, I noticed that compilation of our projects just stopped compiling after a couple of projects. After looking at the bloop errors, I decided to remove WartRemover from our environment to see if that was cousing the issue. Once removed, Metals started working again.

I removed the following:

addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.2.3")
ThisBuild / wartremoverErrors ++= Seq(
  Wart.ArrayEquals,
  Wart.Recursion
)

ThisBuild / wartremoverExcluded += baseDirectory.value / "code" / "orion" / "ml-config-core" / "src" / "main" / "scala" / "db"

I've included the errors we were seeing.
reports.zip

Here are another set of errors after removing wartremover, but Metals does seem to work.

reports_removed_wartremover.zip

Expected behavior

I expect Metals to be tolerant of Wartremover, and continue to compile all of the code.

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

v1.4.0

Extra context or search terms

wartremover

@andyczerwonka
Copy link
Contributor Author

It looks to be the same problem as scalacenter/bloop#1421 and is a blocker for upgrading for us. We'll revert to 1.3.5 until such time that we have a solution.

@andyczerwonka
Copy link
Contributor Author

Also looks like there's a solution coming. scalacenter/bloop#2485

@agilesteel
Copy link

We ran into the same issue. There is an even smaller reproduction (hello world essentially) that I reported on discord. I'll paste it here. Maybe someone will find it useful:

build.sbt

scalaVersion := "2.13.15"
wartremoverWarnings := Warts.all

project/plugins.sbt

addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.2.3")

src/main/scala/Main.scala

object Main extends App

@tgodzik
Copy link
Contributor

tgodzik commented Oct 25, 2024

Thanks! I think I already have a fix. As soon as it's merged I will release bloop, then probably metals also

@andyczerwonka
Copy link
Contributor Author

@tgodzik can we close this as part of scalacenter/bloop#2485, or just waiting on a release?

@tgodzik
Copy link
Contributor

tgodzik commented Oct 29, 2024

I wanted to fix one thing before the release, should be this week. I will close this issue with the update of default Bloop version

@tgodzik tgodzik added fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket bloop Bloop related tickets labels Nov 4, 2024
@tgodzik tgodzik moved this from Triage to In progress in Metals Issue Board Nov 4, 2024
@andyczerwonka
Copy link
Contributor Author

andyczerwonka commented Nov 4, 2024

I wanted to fix one thing before the release, should be this week. I will close this issue with the update of default Bloop version

@tgodzik Just curious if this fix is coming shortly?

@tgodzik
Copy link
Contributor

tgodzik commented Nov 4, 2024

I will release bloop tomorrow and you can check it out first.

tgodzik added a commit to tgodzik/metals that referenced this issue Nov 6, 2024
@agilesteel
Copy link

I think 2.0.4 has issues. It doesn't even start. See how there is no output for 2.0.4 but there is for 2.0.3?

bloop

Another thing: the screenshot above was taken in Ubuntu (WSL actually). Bloop is available on arm since 2.0 but coursier doesn't want to launch it so cs launch bloop:1.6.0 -- about works but cs launch bloop:2.0.3 -- about doesn't. The screenshot below is from an m2 mac.

mac

@tgodzik
Copy link
Contributor

tgodzik commented Nov 7, 2024

I am doing 2.0.5 release to fix things, but not sure about the second issue. Does it work if you do cs install bloop:2.0.3 ? Or cs launch ch.epfl.scala:bloop-cli_2.12:2.0.3 ?

@agilesteel
Copy link

Actually that second issue disappeared so nevermind. Also I just tested with 2.0.5 and at least it starts 🎉

tgodzik added a commit to tgodzik/metals that referenced this issue Nov 7, 2024
@tgodzik
Copy link
Contributor

tgodzik commented Nov 8, 2024

The update to Bloop 2.0.5 was merged. If testing the nightly, you need to reimport the build for it to effect things. I will do a release next week.

@tgodzik tgodzik closed this as completed Nov 8, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Metals Issue Board Nov 8, 2024
@andyczerwonka
Copy link
Contributor Author

We still don't have a 1.4.1 Metals release, so not sure this should be marked done? I realize it's a bloop issue, but Metals is specific about what version of bloop. I realize we can override, but users won't know to do that when they encounter the issue.

@agilesteel
Copy link

agilesteel commented Nov 14, 2024

I agree. For what it's worth I confirm that it works with the pre-release 1.4.1. The bloop version needs to be explicitly set to 2.0.5 in the settings though. Merely using the 2.0.5 bloop CLI is not enough. The project needs to be generated with 2.0.5. Can't wait for the proper release...

@tgodzik tgodzik added this to the Metals v1.4.1 milestone Nov 14, 2024
@ritschwumm
Copy link

just tried with metals 1.4.1 and the only way to actually get rid of the errors was nuking all .metals and .bloop directories in the project - none of the build commands in metals made the error go away before. is this behaviour expected?

@tgodzik
Copy link
Contributor

tgodzik commented Nov 15, 2024

Did you reimport the build? You can always try to run with a verbose compilation and see if that shows what parameters are exactly used to compile.

@ritschwumm
Copy link

ritschwumm commented Nov 15, 2024

i restarted bloop as requested by metals,

i imported the build, i did a clean compile, i tried "clean and restart build server" "restart build server".

then i stopped code, killed bloop in the terminal and restarted code, then tried all of the above again.

after that i did the nuking and imported the build again for good measure, and everything was fine.

of course it may have been the doctor lying to me :)

@agilesteel
Copy link

Wait am I the only who nukes those folders on a daily bases? 🙈

@tgodzik
Copy link
Contributor

tgodzik commented Nov 15, 2024

The should not be necessary, but reset workspace will do that for you. If that doesn't help would be cool to get some information about what is going wrong.

@agilesteel
Copy link

Oh is that a new button? I'll try and report back...

@tgodzik
Copy link
Contributor

tgodzik commented Nov 15, 2024

image

This one

@ritschwumm
Copy link

ritschwumm commented Nov 15, 2024

@tgodzik makes me wonder - if "clean and restart build server" nukes the .bloop and .metals folders, then why would me doing that manually make any difference? i'll check if it see the same behaviour on one of my other projects.

edit
classical case of PEBKAC: nuking the directories is different in that it removes the bloop error reports, and i mostly looked into those to see whether anything is wrong. so only when they disappeared i started assuming everything is fine.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 16, 2024

It doesn't fully remove .bloop and .metals, only the Bloop artifacts, everything else should not cause any issues. It's just Metals indexes and some information about when was the project last imported etc. And also bloop json files, which should be correct also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bloop Bloop related tickets fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket
Projects
Development

Successfully merging a pull request may close this issue.

4 participants