ElixirLS stopped working: "Unable to find formatter"

Not sure what happened, elixirLS had been working just fine in multiple projects.

When I try to format an elixir file on save I get the following…
image

I tried deleting the .elixir_ls folder to allow ElixirLS to recompile.
I see the following output:

Running /Users/mateo/.vscode/extensions/jakebecker.elixir-ls-0.17.5/elixir-ls-release/launch.sh
Preferred shell is zsh, relaunching
Looking for ASDF install
ASDF install found in /usr/local/opt/asdf/libexec/asdf.sh, sourcing
Installing ElixirLS release v0.17.5
Running in <my project path>
Install complete
[Info  - 10:44:33 AM] Started ElixirLS v0.17.5
[Info  - 10:44:33 AM] Running in <my project path>
[Info  - 10:44:33 AM] ElixirLS built with elixir "1.14.2" on OTP "25"
[Info  - 10:44:33 AM] Running on elixir "1.14.2 (compiled with Erlang/OTP 25)" on OTP "25"
[Info  - 10:44:33 AM] Protocols are not consolidated
[Info  - 10:44:33 AM] Elixir sources not found (checking in /home/build/elixir). Code navigation to Elixir modules disabled.
[Info  - 10:44:33 AM] Received client configuration via workspace/configuration
%{"additionalWatchedExtensions" => [], "autoBuild" => true, "autoInsertRequiredAlias" => true, "dialyzerEnabled" => true, "dialyzerFormat" => "dialyxir_long", "dialyzerWarnOpts" => [], "enableTestLenses" => false, "envVariables" => %{}, "fetchDeps" => false, "languageServerOverridePath" => "", "mixEnv" => "test", "mixTarget" => "", "projectDir" => "", "signatureAfterComplete" => true, "suggestSpecs" => true, "trace" => %{"server" => "off"}}
[Info  - 10:44:33 AM] Loaded DETS databases in 92ms
[Info  - 10:44:33 AM] Registering for workspace/didChangeConfiguration notifications
[Info  - 10:44:33 AM] client/registerCapability succeeded
[Info  - 10:44:33 AM] Registering for workspace/didChangeWatchedFiles notifications
[Info  - 10:44:33 AM] client/registerCapability succeeded
[Info  - 10:44:33 AM] Starting build with MIX_ENV: test MIX_TARGET: host
[Info  - 10:44:34 AM] Compile took 490 milliseconds
[Info  - 10:44:34 AM] [ElixirLS WorkspaceSymbols] Indexing...
[Info  - 10:44:34 AM] [ElixirLS WorkspaceSymbols] Module discovery complete
[Info  - 10:44:34 AM] [ElixirLS WorkspaceSymbols] 24 callbacks added to index
[Info  - 10:44:35 AM] [ElixirLS WorkspaceSymbols] 247 modules added to index
[Info  - 10:44:36 AM] [ElixirLS WorkspaceSymbols] 422 types added to index
[Info  - 10:44:37 AM] [ElixirLS WorkspaceSymbols] 4868 functions added to index

Then nothing else happens…
And when I try to format on save I see

[Error - 10:44:52 AM] Request textDocument/formatting failed.
  Message: project_not_loaded
  Code: -32603 

Also, I dont ever see a build folder get created in .elixir_ls or any dyalizer_tpm folder for that matter.

Any ideas?

3 Likes

Can you create a sample repo that reproduces this problem? It’s hard to tell from the log alone why the project doesn’t get loaded

Hi, I am getting the same notification when working on exs files for a course. I have not created a mix project and until recently I was able to use the formatter without issues. I figured out that version v0.17.4 of the elixirLS plugin introduced this bug and shows this error message when reformatting a file.

1 Like

Do you open single exs scripts or open a directory without mix project? In both scenarios the formatting should work and rely on default formatter settings. For mix project it loads the project and gets formatter options from .formatter.exs

1 Like

this happens on a normal project, in my case a LiveView project where I get this error:

opps

tried to load and image, but my user id is being treated as a new user, after three years of being a member…

I have a folder with all the different exs files for my course that I open with vscode.

I just tried opening just a file directly with the latest elixirls version and in this case the reformatting works as expected without any errors.

I am having the exact same issue on a brand new Mix project, which is a very simple one. ElixirLS isn’t finding a formatter, and then it also crashes and doesn’t work at all beyond syntax highlighting. I just get this message in the Output tab:

[Error - 12:44:13 AM] Stopping server failed
Error: Stopping the server timed out
	at c:\Users\<username>\.vscode\extensions\jakebecker.elixir-ls-0.17.6\out\extension.js:89:9067

Edit: This is clear from the file path reported, but this is on Windows 11. Also, mix compile, mix format, etc. work fine.

Confirmed, I opened Formatter not working in non mix projects · Issue #1022 · elixir-lsp/elixir-ls · GitHub for tracking

Can you share a repo that reproduces the problem?

The formatter issue in non mix projects is fixed in v0.17.7

1 Like

Here’s a repo I just pushed: GitHub - bmitc/elixir-airthings: Airthings HTTP API client

I haven’t used Elixir in a few months, so I don’t know when this began. But this is a fresh Mix project with the latest Elixir (Elixir 1.15.7 / OTP 26) on Windows 11. I haven’t tried yet on Ubuntu through WSL. There’s nothing special going on in the Mix project.

hi @lukaszsamson
I am unable to create a new repo that reproduces the problem. I should mention that all my other elixir repos can run ElixirLS successfully (except for one, totaling 2 repos that don’t work). I cannot discern significant differences between them that would hint at the problem currently.

But I am able to get ElixirLS to work on both repos when I lower the version to 0.17.3 !!!
Anything beyond that does not work.

I can reproduce your crash on windows only. The repo works fine on macos. The language server is not crashing, it’s vscode that closes the connection. It looks like another wonderful case od OTP 26 breaking basic stdio like other ones in Not starting on OTP26 · Issue #886 · elixir-lsp/elixir-ls · GitHub

3 Likes

Thanks for diving in and figuring it out, especially so quickly! Too bad the issue is in OTP itself.

It sounds like if I roll back to using OTP 25 that everything should be working? That’s easy enough for me to do since I’m not using any OTP 26 specific features, that I know of, in any projects at the moment.

I haven’t tested on OTP 25. I opened Crash on windows OTP 26 · Issue #1023 · elixir-lsp/elixir-ls · GitHub for tracking. It seems the issue is caused by message truncation. It can be triggered with completion on empty string when there’s many options. Completions starting from some prefix work fine

1 Like

Thanks for filing the ticket.

Also, I rolled back to OTP 25, and everything seems to be working again as expected. :+1: So that’s good that it seems to be only in OTP 26, for Windows at least.

Reported to OTP repo OTP 26 writes corrupted messages to stdout in latin1 mode on Windows · Issue #7838 · erlang/otp · GitHub

1 Like

I’m experiencing this with OTP 25 on MacOS Ventura 13.5 M1 Max Chipset as well:
Erlang/OTP 25 [erts-13.1.5] [source] [64-bit]

Please be more specific. Do you mean the OTP error? or something else. Do you have a rep that reproduces it?

1 Like

The culprit was on my end. The LS wasn’t able to build due to dependency conflicts in my umbrella application and was resulting in the same “Unable to find formatter” error. Apologies for the unrelated alarm. Though the symptoms were the same

1 Like