From b6e9bab9c40c585a139e32d5060dd0db3b53afaf Mon Sep 17 00:00:00 2001 From: Roo Code Date: Sun, 30 Nov 2025 04:52:28 +0000 Subject: [PATCH] fix: handle PowerShell ENOENT error on Windows when os-name package fails - Wrapped osName() call in try-catch block - Added fallback to basic OS info using Node.js built-in os module - Prevents crash when PowerShell is not available on Windows systems - Fixes #9694 --- src/core/prompts/sections/system-info.ts | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/core/prompts/sections/system-info.ts b/src/core/prompts/sections/system-info.ts index 8adc90a160..93c320b0f4 100644 --- a/src/core/prompts/sections/system-info.ts +++ b/src/core/prompts/sections/system-info.ts @@ -4,11 +4,34 @@ import osName from "os-name" import { getShell } from "../../../utils/shell" export function getSystemInfoSection(cwd: string): string { + // Try to get detailed OS name, but fall back to basic info if it fails + // This prevents ENOENT errors on Windows when PowerShell isn't available + let operatingSystemInfo: string + try { + operatingSystemInfo = osName() + } catch (error) { + // Fallback to basic OS info from Node's built-in os module + const platform = os.platform() + const release = os.release() + const type = os.type() + + // Create a readable OS string based on platform + if (platform === "win32") { + operatingSystemInfo = `Windows ${release}` + } else if (platform === "darwin") { + operatingSystemInfo = `macOS ${release}` + } else if (platform === "linux") { + operatingSystemInfo = `Linux ${release}` + } else { + operatingSystemInfo = `${type} ${release}` + } + } + let details = `==== SYSTEM INFORMATION -Operating System: ${osName()} +Operating System: ${operatingSystemInfo} Default Shell: ${getShell()} Home Directory: ${os.homedir().toPosix()} Current Workspace Directory: ${cwd.toPosix()}