Skip to content

Commit

Permalink
fix: add defensive logging in runtime (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanberg authored Oct 5, 2023
1 parent 960c9aa commit 913e8d6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/next_ls/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ defmodule NextLS.Runtime do
path = System.get_env("PATH")
new_path = String.replace(path, bindir <> ":", "")

with dir when is_list(dir) <- :code.priv_dir(:next_ls) do
with dir when is_list(dir) <- :code.priv_dir(:next_ls),
elixir_exe when is_binary(elixir_exe) <- System.find_executable("elixir") do
exe =
dir
|> Path.join("cmd")
|> Path.absname()

NextLS.Logger.log(logger, "Using `elixir` found at: #{elixir_exe}")

port =
Port.open(
{:spawn_executable, exe},
Expand All @@ -98,7 +101,7 @@ defmodule NextLS.Runtime do
{~c"PATH", String.to_charlist(new_path)}
],
args:
[System.find_executable("elixir")] ++
[elixir_exe] ++
if @env == :test do
["--erl", "-kernel prevent_overlapping_partitions false"]
else
Expand Down Expand Up @@ -178,6 +181,11 @@ defmodule NextLS.Runtime do
}}
else
_ ->
NextLS.Logger.error(
logger,
"Either failed to find the private cmd wrapper script or an `elixir`exe on your PATH"
)

{:stop, :failed_to_boot}
end
end
Expand Down

0 comments on commit 913e8d6

Please sign in to comment.