diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index 62f564f4..62bdc7f1 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -41,7 +41,16 @@ defmodule Expert.Port do # managed programs. shell = System.get_env("SHELL") - {path, 0} = System.cmd(shell, ["-i", "-l", "-c", "cd #{root_path} && echo $PATH"]) + # Ideally, it should contain the path to shell (e.g. `/usr/bin/fish`), + # but it might contain only the name of the shell (e.g. `fish`). + is_fish? = String.contains?(shell, "fish") + + # Fish uses space-separated PATH, so we use the built-in `string join` command + # to join the entries with colons and have a standard colon-separated PATH output + # as in bash, which is expected by `:os.find_executable/2`. + path_command = if is_fish?, do: "string join ':' $PATH", else: "echo $PATH" + + {path, 0} = System.cmd(shell, ["-i", "-l", "-c", "cd #{root_path} && #{path_command}"]) case :os.find_executable(~c"elixir", to_charlist(path)) do false ->