Skip to content

Commit 4dfba22

Browse files
authored
fix: add lsp logging when failing to find an elixir executable (#169)
1 parent 9cfb5cc commit 4dfba22

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

apps/expert/lib/expert/port.ex

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,25 @@ defmodule Expert.Port do
4242
shell = System.get_env("SHELL")
4343

4444
{path, 0} = System.cmd(shell, ["-i", "-l", "-c", "cd #{root_path} && echo $PATH"])
45-
elixir = :os.find_executable(~c"elixir", to_charlist(path))
4645

47-
env =
48-
Enum.map(System.get_env(), fn
49-
{"PATH", _path} -> {"PATH", path}
50-
other -> other
51-
end)
46+
case :os.find_executable(~c"elixir", to_charlist(path)) do
47+
false ->
48+
GenLSP.error(
49+
Expert.get_lsp(),
50+
"Couldn't find an elixir executable for project at #{root_path}. Using shell at #{shell} with PATH=#{path}"
51+
)
52+
53+
{:error, :no_elixir}
5254

53-
{:ok, elixir, env}
55+
elixir ->
56+
env =
57+
Enum.map(System.get_env(), fn
58+
{"PATH", _path} -> {"PATH", path}
59+
other -> other
60+
end)
61+
62+
{:ok, elixir, env}
63+
end
5464
end
5565

5666
@doc """

0 commit comments

Comments
 (0)