fix(cli): restore PATH handling on Windows and fix PowerShell quoting (#785)
Co-Authored-By: Aaron Matthis <rapus95@users.noreply.github.com> Co-Authored-By: Letta <noreply@letta.com>
This commit is contained in:
@@ -54,8 +54,11 @@ export function getShellEnv(): NodeJS.ProcessEnv {
|
||||
// Add ripgrep bin directory to PATH if available
|
||||
const rgBinDir = getRipgrepBinDir();
|
||||
if (rgBinDir) {
|
||||
const currentPath = env.PATH || "";
|
||||
env.PATH = `${rgBinDir}${path.delimiter}${currentPath}`;
|
||||
// Windows uses "Path" (not "PATH"), and env vars are case-insensitive there.
|
||||
// Find the actual key to avoid clobbering the user's PATH.
|
||||
const pathKey =
|
||||
Object.keys(env).find((k) => k.toUpperCase() === "PATH") || "PATH";
|
||||
env[pathKey] = `${rgBinDir}${path.delimiter}${env[pathKey] || ""}`;
|
||||
}
|
||||
|
||||
// Add Letta context for skill scripts
|
||||
|
||||
@@ -17,6 +17,14 @@ function windowsLaunchers(command: string): string[][] {
|
||||
if (!trimmed) return [];
|
||||
const launchers: string[][] = [];
|
||||
const seen = new Set<string>();
|
||||
const powerShellCommand =
|
||||
trimmed.startsWith("&") ||
|
||||
trimmed.startsWith('"') ||
|
||||
trimmed.startsWith("'")
|
||||
? trimmed.startsWith("&")
|
||||
? trimmed
|
||||
: `& ${trimmed}`
|
||||
: trimmed;
|
||||
|
||||
// Default to PowerShell on Windows (same as Gemini CLI and Codex CLI)
|
||||
// This ensures better PATH compatibility since many tools are configured
|
||||
@@ -25,9 +33,14 @@ function windowsLaunchers(command: string): string[][] {
|
||||
"powershell.exe",
|
||||
"-NoProfile",
|
||||
"-Command",
|
||||
trimmed,
|
||||
powerShellCommand,
|
||||
]);
|
||||
pushUnique(launchers, seen, [
|
||||
"pwsh",
|
||||
"-NoProfile",
|
||||
"-Command",
|
||||
powerShellCommand,
|
||||
]);
|
||||
pushUnique(launchers, seen, ["pwsh", "-NoProfile", "-Command", trimmed]);
|
||||
|
||||
// Fall back to cmd.exe if PowerShell fails
|
||||
const envComSpecRaw = process.env.ComSpec || process.env.COMSPEC;
|
||||
|
||||
Reference in New Issue
Block a user