From 887714b139d829af23b7d076488a3d968574d0c4 Mon Sep 17 00:00:00 2001 From: doorgan Date: Thu, 16 Oct 2025 10:43:00 -0300 Subject: [PATCH] fix: add lsp logging when failing to find an elixir executable --- apps/expert/lib/expert/port.ex | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index eaf87ab0..62f564f4 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -42,15 +42,25 @@ defmodule Expert.Port do shell = System.get_env("SHELL") {path, 0} = System.cmd(shell, ["-i", "-l", "-c", "cd #{root_path} && echo $PATH"]) - elixir = :os.find_executable(~c"elixir", to_charlist(path)) - env = - Enum.map(System.get_env(), fn - {"PATH", _path} -> {"PATH", path} - other -> other - end) + case :os.find_executable(~c"elixir", to_charlist(path)) do + false -> + GenLSP.error( + Expert.get_lsp(), + "Couldn't find an elixir executable for project at #{root_path}. Using shell at #{shell} with PATH=#{path}" + ) + + {:error, :no_elixir} - {:ok, elixir, env} + elixir -> + env = + Enum.map(System.get_env(), fn + {"PATH", _path} -> {"PATH", path} + other -> other + end) + + {:ok, elixir, env} + end end @doc """