scalameta / metals

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

no build target found and Could not load snapshot text for for a particular file #6584

Open doofin opened 1 month ago

doofin commented 1 month ago

Describe the bug

when I try to show the type of a variable it doesn't work, or just shown as Any when I insert type with code action. The code is fine and sbt compile works.

It happens in a cross js jvm project, not sure how to reproduce yet

metals .log: `2024.07.11 11:14:11 INFO no build target found for /path/to/xx.scala. Using presentation compiler with project's scala-library version: 2.13.14

2024.07.11 11:19:23 WARN Could not load snapshot text for /path/to/xx.scala`

Expected behavior

should be able to show the type of a variable

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

1.3.2

Extra context or search terms

scala 2.13.14 sbt.version=1.5.8

tgodzik commented 1 month ago

Thanks for reporting! This looks like the file is not recognized as part of the build structure. We would some more details however for a reproduction. If it is using Bloop, what build targets are generated, you can also check those targets in the doctor and see if there is one that is responsible for the file at hand.

doofin commented 1 month ago

yeah it's using bloop, The doctor shows ok status for the project containing the file(only complaint is that java src is missing but those are pure Scala files).

tgodzik commented 1 month ago

Still, we would need some more details. It's hard to see what is going on without a reproduction even a minimal one

doofin commented 1 month ago

are there more places for details aside from metals.log and doctor ?

tgodzik commented 1 month ago

You can click on the targets in the metals doctor to get all the info that metals has, for example what it considers to be sources for each module. There should be one for js, jvm and native if enabled.