Skip to content

Commit d04fa6a

Browse files
gnoviawanclaude
andcommitted
fix: prioritize explicit shell paths over PATH in detection and resolution
The shell detection and resolution were checking PATH entries before explicit paths, causing the wrong PowerShell version to be found. Changes: - lib.rs: Check PowerShell 7 explicit paths BEFORE PATH entries in get_available_shells() - manager.rs: Check explicit paths BEFORE PATH entries in resolve_shell_path() This ensures PowerShell 7 (C:\Program Files\PowerShell\7\pwsh.exe) is found and used when installed, rather than falling back to Windows PowerShell 5 (powershell.exe) from PATH. Fixes #59 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent eca0465 commit d04fa6a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src-tauri/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,17 @@ fn get_available_shells() -> Vec<ShellInfo> {
204204

205205
#[cfg(target_os = "windows")]
206206
{
207+
// CRITICAL: Check explicit paths FIRST, then PATH entries
208+
// This ensures the correct shell is found when multiple versions exist
207209
let mut candidates = vec![
210+
// PowerShell 7 explicit paths (checked first)
211+
("pwsh", r"C:\Program Files\PowerShell\7\pwsh.exe", None),
212+
("pwsh", r"C:\Program Files\PowerShell\6\pwsh.exe", None),
213+
// Windows PowerShell 5 (explicit path)
214+
("powershell", r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", None),
215+
// PATH-based fallbacks (checked last)
216+
("pwsh", "pwsh.exe", None),
208217
("powershell", "powershell.exe", None),
209-
("pwsh", "pwsh.exe", None), // PowerShell 7 via PATH
210-
("pwsh", "C:\\Program Files\\PowerShell\\7\\pwsh.exe", None), // PowerShell 7 explicit path
211218
("cmd", "cmd.exe", None),
212219
("wsl", "wsl.exe", None),
213220
];

src-tauri/src/pty/manager.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,12 +994,17 @@ impl PtyManager {
994994
}
995995

996996
// Try PowerShell variants
997+
// CRITICAL: Check explicit paths FIRST, then PATH
997998
if shell == "powershell" || shell == "pwsh" {
998999
let paths = vec![
999-
"pwsh.exe",
1000-
"powershell.exe",
1000+
// PowerShell 7 explicit paths (checked first)
10011001
r"C:\Program Files\PowerShell\7\pwsh.exe",
10021002
r"C:\Program Files\PowerShell\6\pwsh.exe",
1003+
// Windows PowerShell 5 explicit path
1004+
r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe",
1005+
// PATH-based fallbacks (checked last)
1006+
"pwsh.exe",
1007+
"powershell.exe",
10031008
];
10041009
for path in paths {
10051010
if let Some(abs_path) = self.get_absolute_shell_path(path) {

0 commit comments

Comments
 (0)