mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-10 03:28:03 +00:00
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
This commit is contained in:
parent
4591e960ed
commit
b6e9bab9c4
1 changed files with 24 additions and 1 deletions
|
|
@ -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()}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue