elixir-lsp / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
https://elixir-lsp.github.io/elixir-ls/
Apache License 2.0
1.5k stars 196 forks source link

Can't continue due to errors on dependencies error: tell the client #1025

Open emmanueltouzery opened 1 year ago

emmanueltouzery commented 1 year ago

Environment

Current behavior

When I change branch in my elixir project, elixirls fails to start and requires me to call mix deps.get. I consider this normal. The dependencies are quite different between the branches. I just run mix deps.get and that fixes the issue.

However, I do not get any warning in my editor that the LSP is disabled due to that issue.

If I ask my editor to show me the LSP log file, then I can see the message:

Process #PID<0.256.0> raised an exception
** (Mix.Error) Can't continue due to errors on dependencies
    (mix 1.15.7) lib/mix.ex:577: Mix.raise/2
    (mix 1.15.7) lib/mix/tasks/deps.loadpaths.ex:47: Mix.Tasks.Deps.Loadpaths.run/1
    (mix 1.15.7) lib/mix/task.ex:455: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.7) lib/mix/tasks/loadpaths.ex:36: Mix.Tasks.Loadpaths.run/1
    (mix 1.15.7) lib/mix/task.ex:455: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.7) lib/mix/tasks/compile.ex:135: Mix.Tasks.Compile.run/1
    (mix 1.15.7) lib/mix/task.ex:455: anonymous fn/3 in Mix.Task.run_task/5
    (language_server 0.17.8) lib/language_server/build.ex:337: ElixirLS.LanguageServer.Build.run_mix_compile/0

However this is not very handy, I would like to be proactively warned that I should take this step of refetching the dependencies.

Expected behavior

I believe a clean solution would be for elixirls to "catch this error", tell the client, and then "rethrow it" -- sorry about the terminology, I'm pretty sure that's not proper elixir talk... And my understanding is that this is possible through the LSP protocol, and elixirls already does that in one place:

 JsonRpc.show_message(:warning, "OTP compiled without EEP48 documentation chunks")

It would be great if such an "error" (instead of warning in the example I pasted) message was sent if the dependencies are not up-to-date and elixirls cannot operate.

hez commented 7 months ago

I am getting this error with

It be nice to know what is causing to fail?

lukaszsamson commented 7 months ago

Anything. The error comes from mix and it's not very descriptive. Do you have a repo that reproduces it reliably?

hez commented 7 months ago

Anything. The error comes from mix and it's not very descriptive. Do you have a repo that reproduces it reliably?

Yes, it is private sadly... I am beginning to wonder if it is Oban Pro+Web as they run in a separate repo and require auth.

kybishop commented 4 months ago

I'm seeing the same error. We also use Oban Pro... going to look into that as the source of the problem.

kybishop commented 4 months ago

Not sure the cause for us but deleting .elixir_ls seems to have fixed the problem.