From 218112c71a7cd388ccbca6249215aaa45f532c9a Mon Sep 17 00:00:00 2001 From: Leon Qadirie <39130739+leonqadirie@users.noreply.github.com> Date: Sat, 20 Dec 2025 09:42:17 -0300 Subject: [PATCH 1/4] fix: support Nushell for PATH detection Adds Nushell (`nu`) support to `path_env_at_directory/2`. Nushell differs from POSIX shells in two ways: - The `&&` operator is not supported (requires `;` or `and`) - PATH is stored as a list in `$env.PATH`, not a colon-separated string Currently, Expert crashes immediately when `SHELL` is set to Nushell: ``` Error: nu::parser::shell_andand x The '&&' operator is not supported in Nushell ,-[source:1:39] 1 | cd /path/to/project && printf "EXPERT_PATH:%s:EXPERT_PATH" "$PATH" : ^| : `-- instead of '&&', use ';' or 'and' ``` ## Changes - Add `"nu"` case in `path_env_at_directory/2` that uses `;` for command chaining and `$env.PATH | str join ":"` to convert the PATH list to a colon-separated string. --- apps/expert/lib/expert/port.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index e98f6deb..d0b1f628 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -106,6 +106,15 @@ defmodule Expert.Port do ["-l", "-c", cmd] + "nu" -> + # Nushell stores PATH as a list in $env.PATH, so we join with colons. + # Nushell doesn't support && operator, use ; instead. + # No -i flag as it causes issues similar to fish. + cmd = + "cd #{directory}; print (\"#{@path_marker}\" + \":\" + ($env.PATH | str join \":\") + \":\" + \"#{@path_marker}\")" + + ["-l", "-c", cmd] + _ -> cmd = "cd #{directory} && printf \"#{@path_marker}:%s:#{@path_marker}\" \"$PATH\"" ["-i", "-l", "-c", cmd] From 94c723a6a0253bb07369deefa00fa264ee36673f Mon Sep 17 00:00:00 2001 From: Leon Qadirie <39130739+leonqadirie@users.noreply.github.com> Date: Sat, 20 Dec 2025 09:50:44 -0300 Subject: [PATCH 2/4] chore: remove misleading comment --- apps/expert/lib/expert/port.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index d0b1f628..f847dbe8 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -109,7 +109,6 @@ defmodule Expert.Port do "nu" -> # Nushell stores PATH as a list in $env.PATH, so we join with colons. # Nushell doesn't support && operator, use ; instead. - # No -i flag as it causes issues similar to fish. cmd = "cd #{directory}; print (\"#{@path_marker}\" + \":\" + ($env.PATH | str join \":\") + \":\" + \"#{@path_marker}\")" From 6618fd3af59eea12338be7eac219fcf580523baf Mon Sep 17 00:00:00 2001 From: Leon Qadirie <39130739+leonqadirie@users.noreply.github.com> Date: Sat, 20 Dec 2025 09:56:23 -0300 Subject: [PATCH 3/4] refactor: align interpolation style with existing code --- apps/expert/lib/expert/port.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index f847dbe8..096b49d1 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -110,7 +110,7 @@ defmodule Expert.Port do # Nushell stores PATH as a list in $env.PATH, so we join with colons. # Nushell doesn't support && operator, use ; instead. cmd = - "cd #{directory}; print (\"#{@path_marker}\" + \":\" + ($env.PATH | str join \":\") + \":\" + \"#{@path_marker}\")" + "cd #{directory}; print $\"#{@path_marker}:($env.PATH | str join \":\"):#{@path_marker}\"" ["-l", "-c", cmd] From 7c8a8b9b6007d61825c73adab778623c75c86b03 Mon Sep 17 00:00:00 2001 From: Leon Qadirie Date: Sat, 20 Dec 2025 11:29:38 -0300 Subject: [PATCH 4/4] fix: format --- apps/expert/lib/expert/port.ex | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/expert/lib/expert/port.ex b/apps/expert/lib/expert/port.ex index 096b49d1..8a89e96e 100644 --- a/apps/expert/lib/expert/port.ex +++ b/apps/expert/lib/expert/port.ex @@ -107,12 +107,12 @@ defmodule Expert.Port do ["-l", "-c", cmd] "nu" -> - # Nushell stores PATH as a list in $env.PATH, so we join with colons. - # Nushell doesn't support && operator, use ; instead. - cmd = - "cd #{directory}; print $\"#{@path_marker}:($env.PATH | str join \":\"):#{@path_marker}\"" + # Nushell stores PATH as a list in $env.PATH, so we join with colons. + # Nushell doesn't support && operator, use ; instead. + cmd = + "cd #{directory}; print $\"#{@path_marker}:($env.PATH | str join \":\"):#{@path_marker}\"" - ["-l", "-c", cmd] + ["-l", "-c", cmd] _ -> cmd = "cd #{directory} && printf \"#{@path_marker}:%s:#{@path_marker}\" \"$PATH\""