From 31f42c1b6b9a3e9badab8b408937e81880bfdbaa Mon Sep 17 00:00:00 2001 From: doorgan Date: Sat, 15 Nov 2025 15:03:20 -0300 Subject: [PATCH 1/2] fix: trim PATH returned by shell it may include irrelevant information like "Session restored: ..." --- apps/expert/lib/expert/port.ex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index 6f4bb710..070ee97b 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -84,6 +84,9 @@ defmodule Expert.Port do path end + |> String.trim() + |> String.split("\n") + |> List.last() end @doc """ From c9462767a72ea3fada208163b36483300e256be6 Mon Sep 17 00:00:00 2001 From: doorgan Date: Sat, 15 Nov 2025 15:13:13 -0300 Subject: [PATCH 2/2] fix: don't case into pipe --- apps/expert/lib/expert/port.ex | 43 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index 070ee97b..cffb0e62 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -64,26 +64,29 @@ defmodule Expert.Port do env = [{"SHELL_SESSIONS_DISABLE", "1"}] - case Path.basename(shell) do - # 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`). - "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, 0} = - System.cmd(shell, ["-i", "-l", "-c", "cd #{directory} && string join ':' $PATH"], - env: env - ) - - path - - _ -> - {path, 0} = - System.cmd(shell, ["-i", "-l", "-c", "cd #{directory} && echo $PATH"], env: env) - - path - end + path = + case Path.basename(shell) do + # 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`). + "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, 0} = + System.cmd(shell, ["-i", "-l", "-c", "cd #{directory} && string join ':' $PATH"], + env: env + ) + + path + + _ -> + {path, 0} = + System.cmd(shell, ["-i", "-l", "-c", "cd #{directory} && echo $PATH"], env: env) + + path + end + + path |> String.trim() |> String.split("\n") |> List.last()