Skip to content

Commit b41ade7

Browse files
committed
attempt to fix dialyzer error by removing beam
1 parent e49a3a5 commit b41ade7

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

apps/language_server/lib/language_server/dialyzer.ex

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,29 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
308308
end
309309

310310
{:exit, reason}, file_changes ->
311-
# on elixir >= 1.14 reason will actually be {beam_path, reason} but
312-
# it's not easy to pattern match on that
311+
# on elixir >= 1.14 reason will actually be {beam_path, reason}
312+
313313
message = "Unable to process one of the beams: #{Exception.format_exit(reason)}"
314314
Logger.error(message)
315315

316-
JsonRpc.telemetry(
317-
"dialyzer_error",
318-
%{"elixir_ls.dialyzer_error" => message},
319-
%{}
320-
)
316+
case reason do
317+
{beam_path, _inner_reason} when is_binary(beam_path) or is_list(beam_path) ->
318+
case File.rm_rf(beam_path) do
319+
{:ok, _} ->
320+
Logger.info("Beam file #{inspect(beam_path)} removed")
321+
:ok
322+
rm_error ->
323+
Logger.warning("Unable to remove beam file #{inspect(beam_path)}: #{inspect(rm_error)}")
324+
JsonRpc.show_message(
325+
:error,
326+
"ElixirLS Dialyzer is unable to process #{inspect(beam_path)}. Please remove it manually")
327+
end
328+
_ ->
329+
JsonRpc.show_message(
330+
:error,
331+
"ElixirLS Dialyzer is unable to process one of the beam files. Please remove .elixir_ls/dialyzer* directory manually")
332+
:ok
333+
end
321334

322335
file_changes
323336
end)

0 commit comments

Comments
 (0)