scalameta / metals

Scala language server with rich IDE features 🚀

Home Page:https://scalameta.org/metals/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Missing valid Bloop build" when opening existing project for the first time

ghostbuster91 opened this issue · comments

Describe the bug

When trying to open an existing project for the first time metals fails with the following error:

Missing valid Bloop build in /home/kghost/workspace/demos/.bloop.

  1. Did you run bloop outside of the working directory of your build?
     If so, change your current directory or point directly to your `.bloop` directory via `--config-dir`.

  2. Did you forget to generate configuration files for your build?
     Check the installation instructions https://scalacenter.github.io/bloop/setup
    

This was not happening on 1.2.1
Tested both with neovim and vs-code.

If I run manually sbt bloopInstall and then open the project, everything works fine and there is no such error.

Screencast.from.2024-04-25.14-08-14.webm

Expected behavior

I would expect metals to detect that there is no .bloop directory and ask if it should import the project as it was before.

Operating system

Linux

Editor/Extension

Nvim (nvim-metals)

Version of Metals

1.3.0

Extra context or search terms

bloop

Thanks for reporting! It looks like it started Bloop without asking to import the build. Is it happening in more projects for you? I can't reproduce it currently when opening a new workspace 🤔

It looks like it started Bloop without asking to import the build

Correct.

Is it happening in more projects for you?

It happened in a commercial project and then I setup a new small project and it happened also there. So by now I am pretty confident that it will happen in every project.

I can't reproduce it currently when opening a new workspace

Hmm that's not good 🙃

We did change some things related to that, so this might be an actual issue, but I wonder why it happens for you. Did you try any of the new settings that come with 1.3.0?

I don't think so, I only updated metals version. No changes besides that.

@tgodzik what bloop version do you use?

I have:

bloop v1.5.17

Using Scala v2.12.19 and Zinc v1.9.6
Running on Java JDK v19.0.2 (/nix/store/6375rn8kiq9pn4pgdkdiqgvg8b0gdycy-openjdk-19.0.2+7/lib/openjdk)
  -> Supports debugging user code, Java Debug Interface (JDI) is available.
Maintained by the Scala Center and the community.

I don't think it's related to Bloop. It's correctly saying that there is no targets because nothing was imported yet.

Mystery solved. I was previously using bloop 1.5.15.
After upgrading to 1.5.17 I did rm -rf .bloop .metals .sbt **/target .bsp in the project directory and also killed all jvm apps (including old bloop) thinking that this will be sufficient.

But it wasn't. After running git clean -xdf following additional directories were removed:

Removing project/.bloop/
Removing project/metals.sbt
Removing project/project/

After that opening the project correctly prompted for importing.

I think that we can close the issue unless you think that there is some improvement to be made to handle such scenarios better.

After upgrading to 1.5.17 I did rm -rf .bloop .metals .sbt **/target .bsp in the project directory and also killed all jvm apps (including old bloop) thinking that this will be sufficient.

You shouldn't need to do any of that, though if .bloop existed that would explain why we were not asking to import. It looked like it was already imported. Bloop version change should not be a reason to delete anything.

I see, so it turns out it was because of the precautions I took. Lesson learned :)

Thanks for the help @tgodzik !