Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add defensive logging in runtime #276

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading