Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annoying red highlighting of the whole mix.exs #132

Closed
crabvk opened this issue Aug 13, 2020 · 16 comments
Closed

Annoying red highlighting of the whole mix.exs #132

crabvk opened this issue Aug 13, 2020 · 16 comments
Labels
duplicate This issue or pull request already exists

Comments

@crabvk
Copy link

crabvk commented Aug 13, 2020

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?

@wingyplus
Copy link
Contributor

Can you please copy the output from Output tab in vscode to this issue?

@crabvk
Copy link
Author

crabvk commented Aug 15, 2020

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

@jameskentTX
Copy link

jameskentTX commented Aug 20, 2020

@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.

@axelson
Copy link
Member

axelson commented Aug 21, 2020

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.

@crabvk
Copy link
Author

crabvk commented Aug 26, 2020

@axelson
I'm using vscode 1.48.2 with JakeBecker.elixir-ls, what language server client am I using?

@cjbottaro
Copy link

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

@jjcarstens
Copy link
Contributor

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)

@axelson
Copy link
Member

axelson commented Dec 12, 2020

@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.

@dsnipe
Copy link

dsnipe commented Apr 13, 2021

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?

@dersmon
Copy link

dersmon commented Apr 29, 2021

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.

@ConnorRigby
Copy link

bump

@lovebes
Copy link

lovebes commented Aug 16, 2021

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.

@That-David-Guy
Copy link

From here JakeBecker/elixir-ls#71 (comment) :

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

@rossvz
Copy link

rossvz commented Jan 3, 2022

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.

@cognivore
Copy link

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.

@lukaszsamson lukaszsamson added the duplicate This issue or pull request already exists label Oct 7, 2022
@lukaszsamson
Copy link
Collaborator

Duplicate of elixir-lsp/elixir-ls#120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests