vscode-elixir-ls
vscode-elixir-ls copied to clipboard
Annoying red highlighting of the whole mix.exs
If a project has problems with deps (or some other errors), the whole mix.exs is highlighted red. This is annoying and interferes with editing the file. Is there an option to disable highlighting of mix.exs, or maybe highlight only the first line of it?
Can you please copy the output from Output tab in vscode to this issue?
Started ElixirLS v0.5.0
Elixir version: "1.10.4 (compiled with Erlang/OTP 23)"
Erlang version: "23"
ElixirLS compiled with Elixir 1.7.4 and erlang 20
MIX_ENV: test
MIX_TARGET:
[Warn - 6:38:06 PM] Unchecked dependencies for environment test:
[Warn - 6:38:06 PM] * telemetry_metrics (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * phoenix_live_dashboard (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * ecto_sql (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * telemetry_poller (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * gettext (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * jason (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * phoenix_html (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * phoenix (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * postgrex (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * plug_cowboy (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
[Warn - 6:38:06 PM] * phoenix_ecto (Hex package)
[Warn - 6:38:06 PM] the dependency is not available, run "mix deps.get"
18:38:06.987 [error] Process #PID<0.126.0> raised an exception
** (Mix.Error) Can't continue due to errors on dependencies
(mix 1.10.4) lib/mix.ex:392: Mix.raise/1
(mix 1.10.4) lib/mix/tasks/deps.loadpaths.ex:28: Mix.Tasks.Deps.Loadpaths.run/1
(mix 1.10.4) lib/mix/task.ex:330: Mix.Task.run_task/3
(mix 1.10.4) lib/mix/tasks/loadpaths.ex:35: Mix.Tasks.Loadpaths.run/1
(mix 1.10.4) lib/mix/task.ex:330: Mix.Task.run_task/3
(mix 1.10.4) lib/mix/tasks/compile.ex:90: Mix.Tasks.Compile.run/1
(mix 1.10.4) lib/mix/task.ex:330: Mix.Task.run_task/3
(language_server 0.5.0) lib/language_server/build.ex:204: ElixirLS.LanguageServer.Build.compile/0
@vyachkonovalov
I had the same problem when I updated few dependencies in original project from github. Red highlighting of the whole mix.exs is a result of problems with dependencies in your project.
Is there an option to disable highlighting of mix.exs, or maybe highlight only the first line of it?
This happens when the language server returns an error without a line number. Perhaps the language server client you're using can be configured to show such errors by highlighting only the first line? I know that emac's lsp-mode
made a change a month or two ago that made such errors not highlight every single line.
@axelson I'm using vscode 1.48.2 with JakeBecker.elixir-ls, what language server client am I using?
My mixfile (umbrella) is always covered in red. The problems tab seems to indicate it's a problem with elixir-ls.
an exception was raised:
** (FunctionClauseError) no function clause matching in String.split/3
(elixir 1.11.2) lib/string.ex:473: String.split(nil, ":", [])
(stdlib 3.13.2) erl_eval.erl:680: :erl_eval.do_apply/6
(stdlib 3.13.2) erl_eval.erl:888: :erl_eval.expr_list/6
(stdlib 3.13.2) erl_eval.erl:411: :erl_eval.expr/5
(stdlib 3.13.2) erl_eval.erl:449: :erl_eval.expr/5
(elixir 1.11.2) src/elixir.erl:280: :elixir.recur_eval/3
(elixir 1.11.2) src/elixir.erl:265: :elixir.eval_forms/3
(elixir 1.11.2) lib/code.ex:341: Code.eval_string_with_error_handling/3
FWIW, I find that this happens anytime I change a dependency in the mix.exs
file (or add something that breaks it). It seems to get the build in a stuck state (as if cached and can't detect new changes past the error?).
Anyway, I can typically resolve by doing rm -rf .elixir_ls/build
then reload the window (or manually save the file to trigger ElixirLS to run again)
@cjbottaro if that's the full stacktrace then it looks like ElixirLS isn't failing in ElixirLS's code. So my guess is that you have something either in your mix.exs
or config.exs
that is failing to parse correctly, and might be related to an environment variable. But as @jjcarstens mentions you should try running rm -rf .elixir_ls
and restarting your editor first.
I have the same issue with the umbrella application. It happens every time when dependencies are changed, which can be quite often. @axelson Could you explain, please, a bit more how it could be related to an environment variable?
Same problem for me with an umbrella project. Just a hunch:
ElixirLS only checks the top-level mix.exs for dependeny changes in order to trigger updates to its internal book keeping concerning dependencies. So when you add a new dependency to one of your apps' mix.exs and install it, it fails to re-evaluate the umbrella project's deps directory.
@jjcarstens solution also works for me.
bump
Question. Is there a way to introduce some environment variable during the mix deps.get
that is being run whlie building out .elixir_ls
? In my config/config.exs
I have this:
config :goth, json: System.get_env("GOOGLE_APPLICATION_CREDENTIALS") |> File.read!()
.. and elixir-ls can't find the environment variable, because that is set via direnv
.
If only I can run direnv allow
in the terminal/shell session where elixirls is doing its thing, then it might work.
Else I might have to just conditionally |> File.read!()
in the config.
From here https://github.com/JakeBecker/elixir-ls/issues/71#issuecomment-455335633 :
I was able to make this stop happening by changing 2 configuration settings in ElixirLS:
- uncheck Fetch Deps automatically option
- changed Project Dir to . (it was empty and had a red error alert around it)
When I restarted VScode the issue was resolved. This does mean that you have to run mix deps.get and deps.compile manually when you make changes, but I kind of prefer that--I know the state of things in my conceptual understanding of my deps :)
This solved the issue for me
I tried the solution from @That-David-Guy which didn't seem to resolve. Manually removing the entire .elixir_ls/build
directory occassionally does fix it for me, but with a large project and a number of dependencies it takes too long to recompile everything. At this point I just always expect the mix.exs file to be red constantly. Even going into that file to bump a version number results in the entire thing going red.
I wonder how to, in general, debug stuff like this.
I had ElixirLS completely broken for half an hour today, and then I did some random stuff and I fixed it.
It seemed to have failed to parse mix credo output, which, I presume, was complaining about a crash, but I couldn't even see the whole log...
And of course, this UX peculiarity plagues my workflow as well.
Duplicate of https://github.com/elixir-lsp/elixir-ls/issues/120