Open NoBrainSkull opened 4 months ago
I cannot reproduce that. Formatting a live_view project works on my machine. Note that there were no changes that could affect formatting between v0.22.0 and v0.22.1. Do you have a project that reproduces it reliably?
Sure, please find the link below.
I must add that for 1 second I thought that reverting to v0.22.0 and upgrading again to v0.22.1 solved the issue but removing .elixir_ls
, deps/
and build
made it appear again (after reinstalling, deps and compiling).
Here is the full output I'm having :
LSP[elixirls] Unable to find formatter for /home/no_brain_skull/src/ex17ls/.formatter.exs: "**
(Mix.Error) Formatter plugin Phoenix.LiveView.HTMLFormatter cannot be found
(mix 1.15.0) lib/mix.ex:577: Mix.raise/2
(language_server 0.22.1) lib/language_server/mix_tasks/format.ex:302: anonymous fn/2 in Mix.Tasks.ElixirLSFormat.load_plugins/1
(elixir 1.15.0) lib/enum.ex:2510: Enum.\"-reduce/3-lists^foldl/2-0-\"/3
(language_server 0.22.1) lib/language_server/mix_tasks/format.ex:299: Mix.Tasks.ElixirLSFormat.load_plugins/1
(language_server 0.22.1) lib/language_server/mix_tasks/format.ex:362: Mix.Tasks.ElixirLSFormat.formatter_for_file/2
(language_server 0.22.1) lib/language_server/source_file.ex:277: ElixirLS.LanguageServer.SourceFile.formatter_for/3
(language_server 0.22.1) lib/language_server/providers/formatting.ex:13: ElixirLS.LanguageServer.Providers.Formatting.format/4
(language_server 0.22.1) lib/language_server/server.ex:1280: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2"
And here is the reproduction repo. It's a freshly generated liveview app with nothing special.
@NoBrainSkull Formatting works for me with your repo. Tested on macOS VSCode v0.22.1, elixir 1.17.2, OTP 26
Well I guess the problem is on my end then... For the records, I'm using neovim and installed elixir-ls through Mason.
I do have the problem but I'm fine staying on the v0.22.0 for now. I suggest closing this issue and maybe reopening if someone else has a similar problem ?
Thank you for your time !
I'm also getting the same error at times, and it randomly goes away
I'm also getting an error on neovim (Lazy). Removing the plugin fixes the issue.
Error 12:00:55 lsp.message LSP Message (elixirls) Unable to find formatter for /Users/kabturek/projects/insight/.formatter.exs: "
** (Mix.Error) Formatter plugin Phoenix.LiveView.HTMLFormatter cannot be found\n
(mix 1.17.2) lib/mix.ex:588: Mix.raise/2\n
(language_server 0.22.1) lib/language_server/mix_tasks/format.ex:302: anonymous fn/2 in Mix.Tasks.ElixirLSFormat.load_plugins/1\n
(elixir 1.17.2) lib/enum.ex:2531: Enum.\"-reduce/3-lists^foldl/2-0-\"/3\n
(language_server 0.22.1) lib/language_server/mix_tasks/format.ex:299: Mix.Tasks.ElixirLSFormat.load_plugins/1\n
(language_server 0.22.1) lib/language_server/mix_tasks/format.ex:362: Mix.Tasks.ElixirLSFormat.formatter_for_file/2\n
(language_server 0.22.1) lib/language_server/source_file.ex:277: ElixirLS.LanguageServer.SourceFile.formatter_for/3\n
(language_server 0.22.1) lib/language_server/providers/formatting.ex:13: ElixirLS.LanguageServer.Providers.Formatting.format/4\n
(language_server 0.22.1) lib/language_server/server.ex:1280: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2\n"
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Elixir 1.17.2 (compiled with Erlang/OTP 27)
Elixir Language Server version: v0.22.1 Operating system: Mac Editor or IDE name (e.g. Emacs/VSCode): Neovim Editor Plugin/LSP Client name and version: nvim-lspconfig/mason (default LazyVim config)
getting the same error elixir v1.17.2 live_view v1.0.0-rc.6 macOS
Also getting it for projects with older versions of LiveView. Error disappears if I uninstall the extension.
I was also experiencing this with coc.nvim
after upgrading to Elixir 1.17.2.
Funnily enough, just leaving the editor open for a few minutes resolved the issue. I guess it was compiling, but each interaction was interrupting the process. I confirmed that Elixir.Phoenix.LiveView.HTMLFormatter.beam
was missing from .elixir_ls/build/dev_test/lib/phoenix_live_view/ebin
(actually the phoenix_live_view
directory didn't exist), but it appeared after waiting a bit.
edit: Confirmed that deleting .elixir-ls/build
then opening a .ex
file and waiting for .elixir_ls/build/dev_test/lib/phoenix_live_view
to show up again resolves the issue for me.
I've also been experiencing this issue off and on (in vscode). Sometimes the formatter fixes itself; other times it'll stay broken for days. The best way I've found to fix it when it does remain broken is:
plugins: [TailwindFormatter, Phoenix.LiveView.HTMLFormatter],
from my .formatter.exs
Seems like maybe elixir_ls
sometimes has an issue compiling those plugins and following those steps forces a re-compile.
Had the same issue with styler
.
I fixed it by copying _build/test/lib/styler/
to .elixir_ls/build/test/lib/
.
Just adding in I had this for weeks. Elixir 1.17.2, OTP 27. Tried installing older versions, uninstalling, reinstalling. Nothing worked. Eventually I uninstalled, trashed the .elixir_ls folder, reinstalled an older version and then upgraded and it worked!
I have the same issue with VSCode, ElixirLS 0.23.0, Elixir 1.17.2, and OTP 27.
I tried some of the solutions presented here but none worked for me. However, sometimes just leaving VSCode open resolves the issue as some already pointed out. One weird thing is that I have the VSCode plugin v0.23.1 but the language server is 0.23.0, I'm not sure what is going on there.
Unable to find formatter for some_path/app.html.heex: ** (Mix.Error) Formatter plugin Phoenix.LiveView.HTMLFormatter cannot be found
(mix 1.17.2) lib/mix.ex:588: Mix.raise/2
(language_server 0.23.0) lib/language_server/mix_tasks/format.ex:302: anonymous fn/2 in Mix.Tasks.ElixirLSFormat.load_plugins/1
(elixir 1.17.2) lib/enum.ex:2531: Enum.\"-reduce/3-lists^foldl/2-0-\"/3
(language_server 0.23.0) lib/language_server/mix_tasks/format.ex:299: Mix.Tasks.ElixirLSFormat.load_plugins/1
(language_server 0.23.0) lib/language_server/mix_tasks/format.ex:362: Mix.Tasks.ElixirLSFormat.formatter_for_file/2
(language_server 0.23.0) lib/language_server/source_file.ex:277: ElixirLS.LanguageServer.SourceFile.formatter_for/3
(language_server 0.23.0) lib/language_server/providers/formatting.ex:13: ElixirLS.LanguageServer.Providers.Formatting.format/4
(language_server 0.23.0) lib/language_server/server.ex:1280: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2
Elixir Language Server version: v0.23.0 Operating system: Ubuntu (VSCode Server) Editor or IDE name: VSCode Editor Plugin/LSP Client name and version: vscode-elixir-ls (0.23.1)
One weird thing is that I have the VSCode plugin v0.23.1 but the language server is 0.23.0
This is correct. Plugin versioning is independent from language server versioning.
Same error :
Unable to find formatter for /Users/goulvenclech/Documents/encheres_immo/lib/encheres_immo_web/components/form/combobox.ex: "** (Mix.Error) Formatter plugin Surface.Formatter.Plugin cannot be found
(mix 1.17.2) lib/mix.ex:588: Mix.raise/2
(language_server 0.23.0) lib/language_server/mix_tasks/format.ex:302: anonymous fn/2 in Mix.Tasks.ElixirLSFormat.load_plugins/1
(elixir 1.17.2) lib/enum.ex:2531: Enum.\"-reduce/3-lists^foldl/2-0-\"/3
(language_server 0.23.0) lib/language_server/mix_tasks/format.ex:299: Mix.Tasks.ElixirLSFormat.load_plugins/1
(language_server 0.23.0) lib/language_server/mix_tasks/format.ex:362: Mix.Tasks.ElixirLSFormat.formatter_for_file/2
(language_server 0.23.0) lib/language_server/source_file.ex:277: ElixirLS.LanguageServer.SourceFile.formatter_for/3
(language_server 0.23.0) lib/language_server/providers/formatting.ex:13: ElixirLS.LanguageServer.Providers.Formatting.format/4\n (language_server 0.23.0) lib/language_server/server.ex:1280: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2"
Erlang/OTP 26 Elixir 1.17.2 ElixirLS plugin v0.23.1 ElixirLS v0.23.0 VScode 1.92.2 (Universal) MacOS 14.5 (23F79)
Fixed after following this post on Elixir Forum :
Just adding in I had this for weeks on latest version of ElixirLS (0.23.1). Elixir 1.17.2, OTP 27. Tried installing older versions, uninstalling, reinstalling. Nothing worked. Eventually I uninstalled, trashed the .elixir_ls folder, reinstalled an older version and then upgraded Elixir LS and it worked!
I'm going to close this as there's a confirmed workaround
@lukaszsamson This needs a proper fix.
@lukaszsamson This needs a proper fix.
Agreed @anildigital please send a PR or a reliable repro.
I think I found a reliable repro, it feels like a race condition:
rm -rf .elixir_ls
lib/ex17ls/mailer.ex
, immediately add some spaces and try to save a couple of timesElixir: Restart language server
=> the formatter works again@sabiwara The formatter cannot work until the first build finishes. Formatter API can under that conditions initiate compilation which would conflict with the ongoing compilation. You wouldn't normally run mix format
while mix compile
is under way. To prevent that ElixirLS is using a vendored compiler API that never compiles anything.
Maybe the issue is for big projects for which the compilation is slow, and every new save will trigger a new compilation, delaying the formatter being available?
Naive question, but isn't a mix deps.compile
enough for the formatter? If the deps didn't change it shouldn't care about compiling the project itself, no? (at least for projects not defining custom plugins)
It's not trivial to separate deps.compile
. Deps change (e.g. when you switch branches or edit config). Elixir is pretty bad in deciding what to recompile. There were dozens of nontrivial errors and crashes so it's safest to rebuild on start. There's no easy escape from the initial compile time. I guess the real issue would be if the plugins get unloaded on each subsequent compile. I will need to check that.
The last change that could have affected purging and reloading was d17ee89a30c570b8927df829b3be5a509876e777 introduced in v0.21.0. OP reported that v0.22.0 didn't have the problem while v0.22.1 did. There were no changes affecting build between those versions
Reports on forum thread started on August 22 a few weeks after v0.23 release, but this post states that v0.20 worked OK
Anyone already fixing this somewhere? Any woraround to avoid this error? thanks
Just commenting here to say that I have the same issue
I started seeing this today, after a machine crash. 1.17.2 elixir, latest ElixirLS in VSCode.
rm -rf .elixir-ls/
and Elixir: Restart language server
didn't work for merm -rf .elixir-ls/
and then > Restart Extension Host
did!Cheers
Environment
Elixir 1.17.2 (compiled with Erlang/OTP 27)
Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1] [jit:ns]
Elixir 1.16.3 (compiled with Erlang/OTP 26)
(Mix.Error) Formatter plugin Phoenix.LiveView.HTMLFormatter cannot be found