felixse/FluentTerminal · error · Exception
'${command}' command not found. Exit code: ${process.ExitCod
Error message
'${command}' command not found. Exit code: ${process.ExitCode} What it means
Thrown by FileFinder.GetCommandPath as the final fallback: `where` exited non-zero, no path was returned, AND no error text was captured. This branch reports the raw exit code because the more informative error-message branch did not apply.
Source
Thrown at FluentTerminal.SystemTray/FileFinder.cs:87
{
throw new Exception("Should not happen! 'where' exit code is 0, yet the path is empty.");
}
if (!File.Exists(path))
{
throw new Exception(
"Should not happen! 'where' returned a path that doesn't exist: " + path);
}
return path;
}
if (!string.IsNullOrEmpty(error))
{
throw new Exception($"'{command}' command not found. Error message: " + error);
}
throw new Exception($"'{command}' command not found. Exit code: {process.ExitCode:##########}");
}
}
}
}
}View on GitHub (pinned to ba83ec485e)
Solutions
- Confirm `where` exists on the system (it ships with Windows in System32) and is on PATH for the tray process.
- Increase the mre.WaitOne timeout or read output synchronously to avoid the race that loses the error text.
- Set the profile's shell Location to an absolute path so where-lookup is bypassed.
- Re-run with the tool installed and PATH refreshed.
Example fix
// before
mre.WaitOne(50);
...
throw new Exception($"'{command}' command not found. Exit code: {process.ExitCode:##########}");
// after - wait for completion reliably before deciding
process.WaitForExit();
mre.WaitOne(1000);
throw new Exception($"'{command}' not found (where exit {process.ExitCode}, error: '{error ?? "<none>"}')."); Defensive patterns
Strategy: validation
Validate before calling
// Read where output synchronously to avoid losing the error to a race.
var psi = new ProcessStartInfo("where", command){ UseShellExecute=false, RedirectStandardOutput=true, RedirectStandardError=true };
var p = Process.Start(psi); var stdout = p.StandardOutput.ReadToEnd(); var stderr = p.StandardError.ReadToEnd(); p.WaitForExit();
if (p.ExitCode != 0) throw new Exception($"'{command}' not found (exit {p.ExitCode}): {stderr}"); Try / catch
try { path = command.GetCommandPath(); }
catch (Exception ex) { logger.Warn(ex, "where failed"); path = fallbackAbsoluteProfilePath; } Prevention
- Increase the output-read timeout or read synchronously to avoid the race.
- Bypass where by setting an absolute shell path in the profile.
- Ensure System32\where.exe is present and accessible.
When it happens
Trigger: The `where` process exited with a non-zero code but produced neither a usable stdout path nor a stderr line within the 50 ms ManualResetEvent window, so `error` is empty and only ExitCode is available.
Common situations: `where` exited before output was fully read (race with the 50ms mre.WaitOne); where itself is missing or blocked; antivirus interfered with the child process; PATH lookup failed silently.
Related errors
AI-assisted analysis of felixse/FluentTerminal@ba83ec485e (2026-08-13).
Data as JSON: /api/errors/01180caa0a7699cc.
Report an issue: GitHub.