elixir-lsp/elixir-ls

elixir-ls 0.20.0 Crashes occasionally

Closed this issue · 10 comments

Environment

  • Elixir & Erlang versions (elixir --version): elixir 1.16.2-otp-26 & erlang 26.2.1 (downgraded from erlang 26.2.3 and 26.2.1)
  • Elixir Language Server version: 0.20.0 (I've tried 0.19.0)
  • Operating system: Apple m1 Max MacOS 14.4 Sonoma
  • Editor or IDE name (e.g. Emacs/VSCode): Neovim
  • Editor Plugin/LSP Client name and version: elixir-tools

Current behavior

The Language Server occasionally crashes

[ERROR][2024-03-13 12:59:33] ...lsp/handlers.lua:535	'GenServer ElixirLS.LanguageServer.Tracer terminating\n** (MatchError) no match of right hand side value: {:error, {:file_error, ~c"/Users/elijahkim/dev/listener/.elixir_ls/calls.dets.1", :enoent}}\n    (language_server 0.20.0) lib/language_server/tracer.ex:442: ElixirLS.LanguageServer.Tracer.sync/1\n    (language_server 0.20.0) lib/language_server/tracer.ex:272: ElixirLS.LanguageServer.Tracer.close_table/1\n    (language_server 0.20.0) lib/language_server/tracer.ex:175: anonymous fn/2 in ElixirLS.LanguageServer.Tracer.maybe_close_tables/1\n    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3\n    (language_server 0.20.0) lib/language_server/tracer.ex:174: ElixirLS.LanguageServer.Tracer.maybe_close_tables/1\n    (language_server 0.20.0) lib/language_server/tracer.ex:130: ElixirLS.LanguageServer.Tracer.terminate/2\n    (stdlib 5.2) gen_server.erl:1143: :gen_server.try_terminate/3\n    (stdlib 5.2) gen_server.erl:1339: :gen_server.terminate/10\n    (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3\nLast message: {:"$gen_cast", :save}\nState: %{project_dir: "/Users/elijahkim/dev/listener"}'
[WARN][2024-03-13 12:59:33] ...lsp/handlers.lua:537	"** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{\"id\" => 211, \"jsonrpc\" => \"2.0\", \"method\" => \"textDocument/codeLens\", \"params\" => %{\"textDocument\" => %{\"uri\" => \"file:///Users/elijahkim/dev/listener/lib/listener_web/controllers/callbacks/twilio_controller.ex\"}}}}, :infinity)\n    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started\n    (elixir 1.16.2) lib/gen_server.ex:1103: GenServer.call/3\n    (elixir 1.16.2) lib/stream.ex:482: anonymous fn/4 in Stream.each/2\n    (elixir 1.16.2) lib/stream.ex:1654: Stream.do_element_resource/6\n    (elixir 1.16.2) lib/stream.ex:1828: Enumerable.Stream.do_each/4\n    (elixir 1.16.2) lib/stream.ex:690: Stream.run/1\n    /Users/elijahkim/.local/share/nvim/mason/packages/elixir-ls/launch.exs:18: (file)\n    (elixir 1.16.2) lib/code.ex:1489: Code.require_file/2"
[ERROR][2024-03-13 12:59:33] ...lsp/handlers.lua:535	"Task #PID<0.224.0> started from #PID<0.98.0> terminating\n** (stop) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{\"id\" => 211, \"jsonrpc\" => \"2.0\", \"method\" => \"textDocument/codeLens\", \"params\" => %{\"textDocument\" => %{\"uri\" => \"file:///Users/elijahkim/dev/listener/lib/listener_web/controllers/callbacks/twilio_controller.ex\"}}}}, :infinity)\n    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started\n    (elixir_ls_utils 0.20.0) lib/output_device.ex:34: ElixirLS.Utils.OutputDevice.loop/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\nFunction: #Function<0.88139584/0 in ElixirLS.Utils.OutputDevice.start_link/2>\n    Args: []"

{:error, {:file_error, ~c"/Users/elijahkim/dev/listener/.elixir_ls/calls.dets.1", :enoent}}

I don’t see why it should not crash when its data folder is deleted while it is reading or writing to files there. Please explain what is you workflow and post a way to reproduce.

hey @lukaszsamson thanks for the quick response! I'm not an expert in how everything is wired up in terms of the LSP but I'm using neovim through LazyVim and using the elixir-tools package to install elixir-ls. I tried a new phoenix app and after a few saves (format on save) the Lsp logs look like

[START][2024-03-13 14:52:54] LSP logging initiated
[ERROR][2024-03-13 14:52:54] .../vim/lsp/rpc.lua:734	"rpc"	"elixir-ls"	"stderr"	"Running /Users/elijahkim/.local/share/nvim/mason/packages/elixir-ls/launch.sh\nPreferred shell is bash, relaunching\nLooking for ASDF install\nASDF install found in /Users/elijahkim/.asdf/asdf.sh, sourcing\n"
[ERROR][2024-03-13 14:52:55] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/elijahkim/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.20.0/1.16.2-26/language_server.sh"	"stderr"	"Running /Users/elijahkim/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.20.0/1.16.2-26/launch.sh\nPreferred shell is bash, relaunching\nLooking for ASDF install\nASDF install found in /Users/elijahkim/.asdf/asdf.sh, sourcing\n"
[ERROR][2024-03-13 14:52:55] .../vim/lsp/rpc.lua:734	"rpc"	"elixir-ls"	"stderr"	"Installing ElixirLS release v0.20.0\nRunning in /Users/elijahkim/dev/test_app\n"
[ERROR][2024-03-13 14:52:55] .../vim/lsp/rpc.lua:734	"rpc"	"elixir-ls"	"stderr"	"Install complete\n"
[ERROR][2024-03-13 14:52:55] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/elijahkim/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.20.0/1.16.2-26/language_server.sh"	"stderr"	"Installing ElixirLS release v0.20.0\n"
[ERROR][2024-03-13 14:52:55] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/elijahkim/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.20.0/1.16.2-26/language_server.sh"	"stderr"	"Running in /Users/elijahkim/dev/test_app\n"
[ERROR][2024-03-13 14:52:56] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/elijahkim/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.20.0/1.16.2-26/language_server.sh"	"stderr"	"Install complete\n"
[ERROR][2024-03-13 14:52:57] ...lsp/handlers.lua:535	'Task #PID<0.702.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Router.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Router.beam"]]'
[ERROR][2024-03-13 14:52:57] ...lsp/handlers.lua:535	'Task #PID<0.722.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.beam"]]'
[ERROR][2024-03-13 14:52:57] ...lsp/handlers.lua:535	'Task #PID<0.727.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ErrorJSON.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ErrorJSON.beam"]]'
[ERROR][2024-03-13 14:52:57] ...lsp/handlers.lua:535	'Task #PID<0.748.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Task #PID<0.819.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ConnCase.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ConnCase.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Task #PID<0.834.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageHTML.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageHTML.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Task #PID<0.872.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.CoreComponents.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.CoreComponents.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Task #PID<0.954.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Layouts.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Layouts.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Task #PID<0.1005.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageController.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageController.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Task #PID<0.1052.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.Application.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.Application.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Task #PID<0.1053.0> started from #PID<0.255.0> terminating\n** (File.Error) could not read file ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Telemetry.beam": no such file or directory\n    (elixir 1.16.2) lib/file.ex:384: File.read!/1\n    (language_server 0.20.0) lib/language_server/dialyzer.ex:374: anonymous fn/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n    (elixir 1.16.2) lib/task/supervised.ex:36: Task.Supervised.reply/4\nFunction: &:erlang.apply/2\n    Args: [#Function<16.66572049/1 in ElixirLS.LanguageServer.Dialyzer.get_changed_files_contents/1>, [".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Telemetry.beam"]]'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Router.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Router.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ErrorJSON.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ErrorJSON.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ConnCase.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.ConnCase.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageHTML.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageHTML.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.CoreComponents.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.CoreComponents.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Layouts.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Layouts.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageController.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.PageController.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.Application.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestApp.Application.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:52:58] ...lsp/handlers.lua:535	'Unable to process one of the beams: {".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Telemetry.beam", {%File.Error{reason: :enoent, path: ".elixir_ls/build/test/lib/test_app/ebin/Elixir.TestAppWeb.Telemetry.beam", action: "read file"}, [{File, :read!, 1, [file: ~c"lib/file.ex", line: 384]}, {ElixirLS.LanguageServer.Dialyzer, :"-get_changed_files_contents/1-fun-0-", 1, [file: ~c"lib/language_server/dialyzer.ex", line: 374]}, {Task.Supervised, :invoke_mfa, 2, [file: ~c"lib/task/supervised.ex", line: 101]}, {Task.Supervised, :reply, 4, [file: ~c"lib/task/supervised.ex", line: 36]}]}}'
[ERROR][2024-03-13 14:54:04] ...lsp/handlers.lua:535	'GenServer ElixirLS.LanguageServer.Tracer terminating\n** (MatchError) no match of right hand side value: {:error, {:file_error, ~c"/Users/elijahkim/dev/test_app/.elixir_ls/modules.dets.1", :enoent}}\n    (language_server 0.20.0) lib/language_server/tracer.ex:442: ElixirLS.LanguageServer.Tracer.sync/1\n    (language_server 0.20.0) lib/language_server/tracer.ex:272: ElixirLS.LanguageServer.Tracer.close_table/1\n    (language_server 0.20.0) lib/language_server/tracer.ex:175: anonymous fn/2 in ElixirLS.LanguageServer.Tracer.maybe_close_tables/1\n    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3\n    (language_server 0.20.0) lib/language_server/tracer.ex:174: ElixirLS.LanguageServer.Tracer.maybe_close_tables/1\n    (language_server 0.20.0) lib/language_server/tracer.ex:130: ElixirLS.LanguageServer.Tracer.terminate/2\n    (stdlib 5.2) gen_server.erl:1143: :gen_server.try_terminate/3\n    (stdlib 5.2) gen_server.erl:1339: :gen_server.terminate/10\n    (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3\nLast message: {:"$gen_cast", :save}\nState: %{project_dir: "/Users/elijahkim/dev/test_app"}'
[ERROR][2024-03-13 14:54:04] ...lsp/handlers.lua:535	'Terminating Elixir.ElixirLS.LanguageServer.Tracer: an exception was raised:\n    ** (MatchError) no match of right hand side value: {:EXIT, {:badarg, [{:ets, :update_counter, [#Reference<0.2520905469.504233988.43970>, 20, 524288], [error_info: %{cause: :badkey, module: :erl_stdlib_errors}]}, {:dets_v9, :seg_file_item, 8, [file: ~c"dets_v9.erl", line: 1427]}, {:dets_v9, :seg_file, 8, [file: ~c"dets_v9.erl", line: 1404]}, {:dets_v9, :segment_file, 4, [file: ~c"dets_v9.erl", line: 1379]}, {:dets_v9, :"-output_objs2/7-fun-0-", 8, [file: ~c"dets_v9.erl", line: 726]}, {:file_sorter, :outfun, 2, [file: ~c"file_sorter.erl", line: 1332]}, {:file_sorter, :do_sort, 5, [file: ~c"file_sorter.erl", line: 372]}, {:dets, :do_sort, 5, [file: ~c"dets.erl", line: 2848]}, {:dets, :do_finit, 4, [file: ~c"dets.erl", line: 2223]}, {:dets, :finit, 4, [file: ~c"dets.erl", line: 2171]}, {:dets, :apply_op, 4, [file: ~c"dets.erl", line: 1513]}, {:dets, :do_apply_op, 4, [file: ~c"dets.erl", line: 1377]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 241]}]}}\n        (language_server 0.20.0) lib/language_server/tracer.ex:442: ElixirLS.LanguageServer.Tracer.sync/1\n        (language_server 0.20.0) lib/language_server/tracer.ex:120: anonymous fn/2 in ElixirLS.LanguageServer.Tracer.handle_cast/2\n        (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3\n        (language_server 0.20.0) lib/language_server/tracer.ex:117: ElixirLS.LanguageServer.Tracer.handle_cast/2\n        (stdlib 5.2) gen_server.erl:1121: :gen_server.try_handle_cast/3\n        (stdlib 5.2) gen_server.erl:1183: :gen_server.handle_msg/6\n        (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3'
[WARN][2024-03-13 14:54:05] ...lsp/handlers.lua:537	"** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{\"id\" => 12, \"jsonrpc\" => \"2.0\", \"method\" => \"textDocument/codeLens\", \"params\" => %{\"textDocument\" => %{\"uri\" => \"file:///Users/elijahkim/dev/test_app/lib/test_app/application.ex\"}}}}, :infinity)\n    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started\n    (elixir 1.16.2) lib/gen_server.ex:1103: GenServer.call/3\n    (elixir 1.16.2) lib/stream.ex:482: anonymous fn/4 in Stream.each/2\n    (elixir 1.16.2) lib/stream.ex:1654: Stream.do_element_resource/6\n    (elixir 1.16.2) lib/stream.ex:1828: Enumerable.Stream.do_each/4\n    (elixir 1.16.2) lib/stream.ex:690: Stream.run/1\n    /Users/elijahkim/.local/share/nvim/mason/packages/elixir-ls/launch.exs:18: (file)\n    (elixir 1.16.2) lib/code.ex:1489: Code.require_file/2"
[ERROR][2024-03-13 14:54:05] ...lsp/handlers.lua:535	"Task #PID<0.225.0> started from #PID<0.98.0> terminating\n** (stop) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{\"id\" => 12, \"jsonrpc\" => \"2.0\", \"method\" => \"textDocument/codeLens\", \"params\" => %{\"textDocument\" => %{\"uri\" => \"file:///Users/elijahkim/dev/test_app/lib/test_app/application.ex\"}}}}, :infinity)\n    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started\n    (elixir_ls_utils 0.20.0) lib/output_device.ex:34: ElixirLS.Utils.OutputDevice.loop/1\n    (elixir 1.16.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\nFunction: #Function<0.88139584/0 in ElixirLS.Utils.OutputDevice.start_link/2>\n    Args: []"

I'm not sure how else I can help you but I'm willing to try! If there's anything else I can help with please let me know. What I can promise you is that I'm not nuking or deleting anything on purpose!

enoent error means the directory has been deleted. Can you explain why you delete .elixir_ls directory. ElixirLS will crash if you keep deleting its files. If you insist you are not deleting anything please post a way to reproduce it

I have reproduced this issue on a project which had its .elixir_ls directory. With Erlang 26.2.1 & Elixir 1.16.1-otp-26, the LS will also rebuild the directory if it's deleted, so I suspect that's not the root cause.

With Elixir updated to 1.16.2-otp-26, ElixirLS continues to work. The LS also works when I upgrade to Erlang 26.2.2, but fails when I upgrade to 26.2.3.

Here's the full ElixirLS log:
elixir_ls_log.txt


I don’t see why it should not crash when its data folder is deleted while it is reading or writing to files there.

If you insist you are not deleting anything please post a way to reproduce it

FWIW, while deleting .elixir_ls may be frowned upon, it's an action that some devs will take when things break down. When the LS fails to start, for example, VS Code can't display the Elixir LS commands for restarting the LS, cleaning build files, etc.

Since the directory will be rebuilt even if it has been deleted with previous versions of Erlang/Elixir, I wouldn't solely blame the missing directory for these crashes.

Here's a screen recording where I have ElixirLS running, save some changes, and confirm the LS has reformatted the file. When I delete .elixir_ls and trigger another change, the LS recreates the directory and successfully recompiles. Note the rebar prompt in VS Code.

elixir_ls_rebuild_on_deleted_dir.mov

I have reproduced this issue

No @type1fool, that's an OTP issue, please downgrade to a working version. See https://elixirforum.com/t/crash-dump-when-installing-phoenix-on-mac-m2-eheap-alloc-cannot-allocate-x-bytes-of-memory-of-type-heap-frag/62154/6 erlang/otp#8238

FWIW, while deleting .elixir_ls may be frowned upon, it's an action that some devs will take when things break down

Do you also run mix compile in one terminal while rm -rf _build in the other? The first response should be restarting the language server. The better option would be to reproduce the issue, isolate it and raise a PR fixing it. If you delete the directory all file databases has to be rebuilt.

When I delete .elixir_ls and trigger another change, the LS recreates the directory and successfully recompiles

You are being lucky. If you delete the directory during compilation things will break. If you remove _build, deps or project dir during mix compile it will crash. The only supported and sane approach to resetting Mix state is via restating the OS beam process.

Any updates on this? I have been facing a similar error frequently:

[ElixirLS WorkspaceSymbols] Updating index...
Starting build with MIX_ENV: test MIX_TARGET: host
[ElixirLS WorkspaceSymbols] 2 modules need reindexing
[ElixirLS WorkspaceSymbols] 32 symbols added to index in 9ms
Unable to prune mix project module for nimble_options: ** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.Tracer, :get_project_dir, 5000)
    ** (EXIT) time out
    (elixir 1.16.0) lib/gen_server.ex:1114: GenServer.call/3
    (language_server 0.20.0) lib/language_server/tracer.ex:34: ElixirLS.LanguageServer.Tracer.get_project_dir/0
    (language_server 0.20.0) lib/language_server/tracer.ex:447: ElixirLS.LanguageServer.Tracer.in_project_sources?/1
    (language_server 0.20.0) lib/language_server/tracer.ex:403: ElixirLS.LanguageServer.Tracer.register_call/5
    (elixir 1.16.0) src/elixir_env.erl:30: :elixir_env."-trace/2-lc$^0/1-0-"/3
    (elixir 1.16.0) src/elixir_env.erl:30: :elixir_env.trace/2
    (elixir 1.16.0) src/elixir_dispatch.erl:189: :elixir_dispatch.do_expand_import/7
    (elixir 1.16.0) src/elixir_dispatch.erl:119: :elixir_dispatch.dispatch_import/6
    (elixir 1.16.0) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
    (elixir 1.16.0) src/elixir_expand.erl:46: :elixir_expand.expand/3
    (elixir 1.16.0) src/elixir_expand.erl:10: :elixir_expand.expand/3
    (elixir 1.16.0) src/elixir_expand.erl:548: :elixir_expand.expand_block/5
    (elixir 1.16.0) src/elixir_expand.erl:46: :elixir_expand.expand/3
    (elixir 1.16.0) src/elixir_compiler.erl:45: :elixir_compiler.compile/4
    (elixir 1.16.0) src/elixir_module.erl:426: :elixir_module.eval_form/7
    (elixir 1.16.0) src/elixir_module.erl:128: :elixir_module.compile/7
Terminating Elixir.ElixirLS.LanguageServer.Tracer: an exception was raised:
    ** (MatchError) no match of right hand side value: {:EXIT, {:badarg, [{:ets, :update_counter, [#Reference<0.564526431.3194355717.161965>, 8, 128], [error_info: %{cause: :badkey, module: :erl_stdlib_errors}]}, {:dets_v9, :seg_file_item, 8, [file: ~c"dets_v9.erl", line: 1427]}, {:dets_v9, :seg_file, 8, [file: ~c"dets_v9.erl", line: 1404]}, {:dets_v9, :segment_file, 4, [file: ~c"dets_v9.erl", line: 1379]}, {:dets_v9, :"-output_objs2/7-fun-0-", 8, [file: ~c"dets_v9.erl", line: 726]}, {:file_sorter, :outfun, 2, [file: ~c"file_sorter.erl", line: 1332]}, {:file_sorter, :do_sort, 5, [file: ~c"file_sorter.erl", line: 372]}, {:dets, :do_sort, 5, [file: ~c"dets.erl", line: 2848]}, {:dets, :do_finit, 4, [file: ~c"dets.erl", line: 2223]}, {:dets, :finit, 4, [file: ~c"dets.erl", line: 2171]}, {:dets, :apply_op, 4, [file: ~c"dets.erl", line: 1513]}, {:dets, :do_apply_op, 4, [file: ~c"dets.erl", line: 1377]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 241]}]}}
        (language_server 0.20.0) lib/language_server/tracer.ex:442: ElixirLS.LanguageServer.Tracer.sync/1
        (language_server 0.20.0) lib/language_server/tracer.ex:120: anonymous fn/2 in ElixirLS.LanguageServer.Tracer.handle_cast/2
        (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
        (language_server 0.20.0) lib/language_server/tracer.ex:117: ElixirLS.LanguageServer.Tracer.handle_cast/2
        (stdlib 5.2) gen_server.erl:1121: :gen_server.try_handle_cast/3
        (stdlib 5.2) gen_server.erl:1183: :gen_server.handle_msg/6
        (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

@rauann Your stacktrace is something else. ElixirLS tracer crashes when trying to sync ETS to DETS somewhere inside OTP in :dets.from_ets call. Can you try to isolate it and report to OTP issue tracker? Can you create a minimal repo that reproduces the problem?

I don't have logs handy but I think I've seen this issue caused by running two editors side-by-side both inadvertently using the same .elixir_ls directory. The two instances complete with each other and get into a recompiling loop. This isn't a common case but one way around it (for users that realize it'll be an issue) is to make the .elixir_ls directory configurable.

If that’s the reason then it won’t be easy to address given that OTP does not expose filesystem locks API

Closing as there is no repro