fix: improve Windows compatibility for CLI commands and sandbox (#261)
## Fix Windows compatibility issues (#248) This PR addresses the Windows compatibility issues reported in #248: 1. **Fix sandbox initialization failure on Windows** - Modified `getSandbox()` to return `SandboxType.NONE` on Windows instead of throwing an error - Added a warning log message to inform the user that sandbox is not available on Windows 2. **Fix Unix commands not working on Windows** - Created a new module [platform-commands.ts](cci:7://file:///c:/Users/HP%20840%20G6/workflow/codex/codex-cli/src/utils/agent/platform-commands.ts:0:0-0:0) that automatically adapts Unix commands to their Windows equivalents - Implemented a mapping table for common commands and their options - Integrated this functionality into the command execution process ### Testing Tested on Windows 10 with the following commands: - `ls -R .` (now automatically translates to `dir /s .`) - Other Unix commands like `grep`, `cat`, etc. The CLI no longer crashes when running these commands on Windows. I have read the CLA Document and I hereby sign the CLA --------- Signed-off-by: Alpha Diop <alphakhoss@gmail.com>
This commit is contained in:
@@ -272,7 +272,15 @@ async function getSandbox(runInSandbox: boolean): Promise<SandboxType> {
|
||||
return SandboxType.MACOS_SEATBELT;
|
||||
} else if (await isInLinux()) {
|
||||
return SandboxType.NONE;
|
||||
} else if (process.platform === "win32") {
|
||||
// On Windows, we don't have a sandbox implementation yet, so we fall back to NONE
|
||||
// instead of throwing an error, which would crash the application
|
||||
log(
|
||||
"WARNING: Sandbox was requested but is not available on Windows. Continuing without sandbox.",
|
||||
);
|
||||
return SandboxType.NONE;
|
||||
}
|
||||
// For other platforms, still throw an error as before
|
||||
throw new Error("Sandbox was mandated, but no sandbox is available!");
|
||||
} else {
|
||||
return SandboxType.NONE;
|
||||
|
||||
Reference in New Issue
Block a user