scalameta / metals

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

no build target found for .../.metals/.tmp/Main.scala. Using presentation compiler with project's scala-library version: 2.13.7 #3407

Closed w-r-z-k closed 2 years ago

w-r-z-k commented 2 years ago

Describe the bug

Error reporting isn't showing up in nvim. There's a bug report in nvim-metals that has a detailed description. Since the problem occurs whether I am using the nvim-metals plugin or the lspconfig configuration, I believe this to be a bug in metals.

When I wipe out all .bloop and .bsp and .metals and target folders and edit the source files anew, I am invited to import the build in nvim; and I do. Then I can edit the file. I see errors initially but it quickly stops working.

My particular project has many scala source files, each with its own main entry point, via the object Day1 extends App {} idiom. I suspect that metals doesn't like this at all and stops working. But it's only a theory.

To Reproduce

Steps to reproduce the behavior:

  1. Wipe out all intermediate build files and the .bloop, .metals, and target files.
  2. Edit a scala source file with nvim which is configured to use metals either with nvim-metals or lspconfig
  3. Import the build when offered to do so
  4. Wait for the index and compile to finish an settle down
  5. Introduce a syntax error
  6. See the error reported inline. (Sometimes this works once -- but it's intermittent)
  7. Exit nvim
  8. Edit another file
  9. Introduce a syntax error
  10. No error will be shown
  11. Repeat steps 7 to 10 all you like, error reporting is now not working

The metals log contains the error:

2021.12.27 14:18:45 INFO no build target found for /Users/user/Development/aoc2021/.metals/.tmp/Main6918781775207410564.scala. Using presentation compiler with project's scala-library version: 2.13.7

Expected behavior

I should see an error in the nvim editor.

Screenshots

Where's the red virtual text showing this error?

Screen Shot 2021-12-27 at 2 28 39 PM

Installation:

Additional context

See nvim-metals issue #306

Search terms

metals, bloop, nvim, "no build target found"

w-r-z-k commented 2 years ago

I have figured out why this happens; and it is not related to that message in the log. Simply put: The errors reported in nvim in the file you are editing are based on the results of an overall sbt build not on the errors currently in the file you are editing.

I have a full explanation in the closure report on nvim_metals issue #306