Description
When attempting to execute Shell commands via LocalFilesystemWithShell on Windows, the following exception occurs:
io.agentscope.harness.agent.filesystem.local.LocalFilesystemWithShell -- Command execution failed: Cannot run program "sh" (in directory "E:\agentscope\workspace\3846161173172182283"): CreateProcess error=2, 系统找不到指定的文件。
java.io.IOException: Cannot run program "sh" (in directory "E:\agentscope\workspace\3846161173172182283"): CreateProcess error=2, 系统找不到指定的文件。
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
...
The error occurs because Windows does not have the sh (Unix Shell) command available by default, causing the CreateProcess call to fail.
Steps to Reproduce
- Run the relevant code on a Windows system.
- Invoke
LocalFilesystemWithShell.execute() or use ShellExecuteTool to run a Shell command.
- Observe the console or logs for the above exception.
Expected Behavior
On Windows systems, the code should either:
- Automatically detect the OS and switch to an appropriate shell (e.g.,
cmd or PowerShell).
- Provide clear instructions to the user about how to configure the shell environment.
Root Cause
- The code does not check the operating system type and defaults to using the Unix
sh command.
- There is insufficient cross-platform support for Windows environments.
Environment Information
- OS: Windows
- Working Directory:
E:\agentscope\workspace\3846161173172182283
- Related Modules:
LocalFilesystemWithShell, ShellExecuteTool
Suggested Solutions
- OS Detection: Before executing shell commands, detect the current operating system:
- On Windows, use
cmd /c or PowerShell for command execution.
- On Unix/Linux/macOS, continue using
sh.
- Configurable Shell Path: Allow users to configure a custom shell path via settings or environment variables.
- Documentation: Clearly document that Windows users need to install a
sh-compatible environment (e.g., Git Bash, Cygwin) or use alternative cross-platform command execution methods.
Relevant Code/Logs
See the provided stack trace.
Additional Notes
If this is the first time running this feature on Windows, please consider adding cross-platform compatibility notes to the documentation to help other users avoid similar issues.
Description
When attempting to execute Shell commands via
LocalFilesystemWithShellon Windows, the following exception occurs:The error occurs because Windows does not have the
sh(Unix Shell) command available by default, causing theCreateProcesscall to fail.Steps to Reproduce
LocalFilesystemWithShell.execute()or useShellExecuteToolto run a Shell command.Expected Behavior
On Windows systems, the code should either:
cmdorPowerShell).Root Cause
shcommand.Environment Information
E:\agentscope\workspace\3846161173172182283LocalFilesystemWithShell,ShellExecuteToolSuggested Solutions
cmd /corPowerShellfor command execution.sh.sh-compatible environment (e.g., Git Bash, Cygwin) or use alternative cross-platform command execution methods.Relevant Code/Logs
See the provided stack trace.
Additional Notes
If this is the first time running this feature on Windows, please consider adding cross-platform compatibility notes to the documentation to help other users avoid similar issues.