agentscope-ai / agentscope-ai/agentscope-java

[Bug]:Command Execution Fails on Windows with "Cannot run program 'sh'" Error

Aberta
#1,396 7 comentários 0 reações 1 responsável Reivindicada por @wlgusqkr Ver no GitHub
area/harness bug good first issue help wanted
Linguagem predominante
Java
Estrelas
5.6k
Forks
1.3k
Merge médio
4d 12h
PRs com merge (30d)
77

Descrição

**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**
1. Run the relevant code on a Windows system.
2. Invoke `LocalFilesystemWithShell.execute()` or use `ShellExecuteTool` to run a Shell command.
3. 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**
1. **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`.
2. **Configurable Shell Path**: Allow users to configure a custom shell path via settings or environment variables.
3. **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.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.