Skip to content

Commit 95f8c93

Browse files
committed
fix: remove assumption to fix deterministic builds
Current code has an assumption that `[:compile][:source]` will always exist in the output of `Enum.module_info()`. This is stripped from Elixir's deterministic build toggle (`ERL_COMPILER_OPTIONS=deterministic`). Added an assumption for `~"/"` as a fallback when such a case happens to keep the old logging behaviour. This can be changed as seen fit. Manual testing shows that elixir-ls will no longer throw on startup due to `nil` given as a path with a deterministic build of Elixir. Fixes #1197
1 parent 5d6639f commit 95f8c93

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

apps/language_server/lib/language_server.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ defmodule ElixirLS.LanguageServer do
143143
enum_ex_path = Enum.module_info()[:compile][:source]
144144

145145
elixir_sources_available =
146-
unless File.exists?(enum_ex_path, [:raw]) do
147-
dir = Path.join(enum_ex_path, "../../../..") |> Path.expand()
146+
# handle possible nil from deterministic build of elixir
147+
unless enum_ex_path && File.exists?(enum_ex_path, [:raw]) do
148+
dir = Path.join(enum_ex_path || ~c"/", "../../../..") |> Path.expand()
148149

149150
Logger.notice(
150151
"Elixir sources not found (checking in #{dir}). Code navigation to Elixir modules disabled."

0 commit comments

Comments
 (0)