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 stops working in a module, if a module on which it depends doesn't compile #7079

Open
adamw opened this issue Dec 30, 2024 · 6 comments
Labels
improvement Not a bug or a feature, but something general we can improve

Comments

@adamw
Copy link

adamw commented Dec 30, 2024

Describe the bug

Let's say we have three modules: A, B, C, where B depends on A, and C depends on A (A <- B <- C).

Initially they all compile. If you introduce some changes to A, which cause B to stop compiling, and then try to work in C (without fixing B), features such as import suggestions, highlighting bad code etc. stop working in C.

There's no indication as to why this happens, it seems as if metals doesn't work. Only when the compilation issues in B are fixed, everything starts working in C again.

Expected behavior

A banner in C files which says "IDE features won't work until X, Y, Z modules are fixed and properly compile"

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.4.2

Extra context or search terms

No response

@tgodzik tgodzik added the improvement Not a bug or a feature, but something general we can improve label Dec 31, 2024
@filipwiech
Copy link
Contributor

filipwiech commented Dec 31, 2024

Expected behavior
A banner in C files which says "IDE features won't work until X, Y, Z modules are fixed and properly compile"

Actually, would it be possible for Metals to still provide support in such cases on a best effort basis? 🤔 I would imagine that it should be a better user experience to try and still keep on working, even if it won't be 100% correct/complete. Usually scenarios like that don't break the project completely and most of the code is still fine. I can understand why perhaps diagnostics would be disabled for downstream modules (to avoid unnecessary noise), but things like imports, code completions, hover, navigation etc. could maybe still be active. Not sure if the presentation compiler (which is increasingly being used in Metals in addition to the Semantic DB files) or the new "best effort" mode would help here. Sorry if I misunderstood the problem, or if it's somehow already handled. 🙂

@adamw
Copy link
Author

adamw commented Dec 31, 2024

Hm well maybe code navigation did work, I don't remember now. For sure error highlighting and import suggestions for new classes introduced in A didn't.

Best-effort - definitely, but I'd still give a cue to the user that metals works in "degraded" mode, because module B doesn't compile. That sets the expectations correctly.

I did end up spending quite some time (restarting vs code, metals, removing .metals, .bloop etc) trying to figure out why the IDE stopped working. Only after some time I discovered that an intermediate module does not compile, and that this is the cause.

@tgodzik
Copy link
Contributor

tgodzik commented Jan 17, 2025

We discussed it further today and there are three things we can do to improve:

  • add some messages to status to inform the user that there are issues with compilation
  • fix issues with betasty and make it the default (can be already tested to provide feedback)
  • add compilation errors from the compiler as well for the current file instead of from Bloop (already worked on by @rochala )

We should do at least the first one in the scope of this issue.

@adamw
Copy link
Author

adamw commented Jan 18, 2025

In any non-trivial project there are very often issues with compilation (more often than not), but when working on a specific file what's important is if the current module compiles (and all modules that it depends on). So this information would have to be contextual, answering the following question to the developer:

Is the file I'm currently working on covered by Metals & compilation? Will errors highlight, and import suggestions work?

@rochala
Copy link
Collaborator

rochala commented Jan 18, 2025

It should also contain a reason why metals are not working for the current file / module that we edit.

What I'm thinking is maybe a dynamic status bar that shows the status for the current source ? Similar to our BSP status. Something like this. And when you click on it, it should give you some information right away without running the doctor or anything. I think that there is an API for tooltip which can be markdown https://code.visualstudio.com/api/references/vscode-api#StatusBarItem . It should clearly point issues like:

  • Upstream modules are non-compiling. Some symbols and data may be outdated (until b-tasty)
  • Upstream modules are non-compiling and there are no classjars present. Your IDE most likely won't work. To fix this you have to fix upstream modules first. Remember, do not clean your classjars in this scenario as it will break the IDE until next successful compilation. (also until b-tasty)
  • Can't fetch presentation compiler
  • Presentation compiler crash occurred. Please report it to metals team. You can find it under ...
  • Can't connect to the build server. Try reimporting the build (or clicking this metal may try to do this automatically)

Image

VSCode allows to make it even more noticeable:

Image

Image

@adamw
Copy link
Author

adamw commented Jan 18, 2025

@rochala Sounds great :) such badges as the ESline/Partial Mode ones would be really useful.

One note: I would avoid using terms such as "classjars" or "presentation compiler". I don't even know what classjars are ;) But both are terms used by people familiar with the IDE internals, probably totally not familiar to users. I would just write: "compiler crashed; please report ". Of course, "advanced" details might be available in some further screens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Not a bug or a feature, but something general we can improve
Projects
Status: Triage
Development

No branches or pull requests

4 participants