scalameta / metals

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

Build import is not reliable #2093

Open smarter opened 4 years ago

smarter commented 4 years ago

After onboarding ~270 students with metals my main observation is that the initial build import for a project is just not reliable, even on very simple projects: in many situations it will fail, usually with a timeout connecting to the BSP server. Once that happens, the user has to try various manual steps to get things working, and it's very hard to get students to do this correctly (even with step-by-step instructions: https://gitlab.epfl.ch/lamp/cs210/-/blob/master/labs/example-lab.md#troubleshooting). I don't know what needs to be done to fix this exactly (and things might be completely different when using sbt as a BSP server instead of bloop), but I think metals should try harder to get things working by whatever means it can: retrying the build import, restarting the BSP server, etc.

Installation:

Attached are two metals.log files from two students as samples. metals.log metals-1.log

tgodzik commented 4 years ago

Thanks for reporting! I do agree this step should work almost 100%, though we haven't had issues like that reported too often.

One thing we could do is increase the timeout for connecting to Bloop and maybe do something like 5 retries connecting to bsp server similar to how VS Code does it.

@smarter are the cases here that eventually users were able to connect or did they never manage to do it?

metals-1.log does show things going quite awry, but metals.log seem only to indicate that Metals was shutdown while connecting to Bloop

smarter commented 4 years ago

@smarter are the cases here that eventually users were able to connect or did they never manage to do it?

Not sure as I don't get feedback from everyone, I think most people managed to get it working in the end.

tgodzik commented 4 years ago

@smarter are the cases here that eventually users were able to connect or did they never manage to do it?

Not sure as I don't get feedback from everyone, I think most people managed to get it working in the end.

Ok, so it should be just the case of making it all more reliable.

ColOfAbRiX commented 4 years ago

Adding my personal experience here as I think it might be related: since version 0.9.2 every time I open Metals on VSCode I receive he message "failed to connect to build server" and I'm forced to manually import the build.

tgodzik commented 4 years ago

@ColOfAbRiX Och, that's not good. Could you possibly add your logs to the issues here? I wonder if it's a timeout thing only... Do you run build import and only then Metals is able to connect? What if you use the connect to build server command manually?

ColOfAbRiX commented 4 years ago

Do you want me to open another issue or here is good? What happens is:

  1. Open vscode
  2. Metals starts loading
  3. Get the message Failed to connect
  4. Run import build
  5. All good

I'm running Metals 0.9.4 on VSCode, OS is Windows 10

This procedure is quite consistent in the sense that the failure is always there and importing always fixes it. Using "connect to build server" doesn't help. Clearing all caches (.metals, .bloop) doesn't help either.

Logs are here https://www.heypasteit.com/clip/0IV58J The first part of the log is after I started VSCode, later is when I clicked on "connect to build server"

tgodzik commented 4 years ago

@ColOfAbRiX this seems like a separate issue altogether:

2020.09.28 16:09:23 WARN  Scala instance jar c:\mnt\c\Users\FabrizioColonna\.cache\coursier\v1\https\repo1.maven.org\maven2\org\fusesource\jansi\jansi\1.12\jansi-1.12.jar doesn't exist!

Looks like some files used by Bloop are not there and I think it's due to the fact it's in c:\mnt\c\. I think that mnt directory doesn't exist when you start and after running bloopInstall it is created. I have no idea why sbt is using that path for cache, but this seems to be the issue. No idea why, but maybe are you using WSL? It does seem like an issue is connected to your system specifically. We should work on it in a separate issue for sure.

ColOfAbRiX commented 4 years ago

That's weird. I do use WSL but not with vscode which I start and operate under windows. Under WSL /mnt/c/ is where the C drive is, but c:\mnt\c\ corresponds to nothing I have configured. I'll create a new issue

ckipp01 commented 2 years ago

I'm curious where we are at with this issue? Do we still have significant problems here? @smarter since you originally created this, did you have another group of students? If so, how was the experience?

smarter commented 2 years ago

I think build import is still unreliable but I didn't do much TAing this semester, @mbovel had more hands-on experience :)

mbovel commented 2 years ago

I haven't noticed many build import failures this semester. But I can have a closer look next semester when we do the setup :)

ckipp01 commented 2 years ago

I haven't noticed many build import failures this semester. But I can have a closer look next semester when we do the setup :)

Sounds good, please do let us know!

vishalovercome commented 2 years ago

I've faced this several times and have seen my colleagues switch to IntelliJ (which they use for their Java projects) due to it not working 100% of the time. With the latest Metals we seem to have added a "start button". Perhaps that button can do everything (start, import, compile, refresh test explorer, etc.)

tgodzik commented 2 years ago

@vishalovercome what build tool had that issue? I haven't seen any on projects I worked with.

Unfortunately, we can't run everything under the start button as the import might have already happened, so it would not be neccessary.

vishalovercome commented 2 years ago

Just bloop. It works most of the time but not all of the time. When it doesn't "import build" gets the job done 90% of the time and restarting gets us there in the remaining 10% of the time. Some details about the project:

  1. multi project
  2. scala + java codebase

I never got sbt to work as BSP reliably, but this was when bsp support in sbt was just added

vishalovercome commented 2 years ago

As a datapoint - I faced this problem after upgrading to latest Metals today. Then "import build" -> "sbt bloopInstall" -> all good (except integration tests discovery in test explorer).

tgodzik commented 2 years ago

As a datapoint - I faced this problem after upgrading to latest Metals today. Then "import build" -> "sbt bloopInstall" -> all good (except integration tests discovery in test explorer).

Did you have any kind of logs inside the Metals output or in .metals/metals.log ? I recently updated it to print more messages when it happens.

vishalovercome commented 2 years ago

As I described in another ticket, I had to switch to older metals due to performance problems and don't have the logs anymore. I'll grab them when I face this problem. This problem is further compounded by the fact that even doctor doesn't work reliably all the time - clicking it takes us nowhere at times. Thus its pretty much second nature to import / restart bloop / vscode.

tgodzik commented 2 years ago

I think the performance issue might be coming from the Test Explorer, so if you switch to lenses it should go away.

vishalovercome commented 2 years ago

Performance is a separate issue - my point was that I don't have the logs as I switched to older version due to performance. I'll certainly share the logs when I hit this particular issue