fix: fix swe_workspace_path doesn't exist

This commit is contained in:
seeker 2024-08-05 14:47:20 +08:00
parent fccfa5a9cc
commit 8bd72911e7
2 changed files with 9 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import asyncio
import os
from asyncio import Queue
from asyncio.subprocess import PIPE, STDOUT
from typing import Optional
@ -28,7 +29,7 @@ class Terminal:
async def _start_process(self):
# Start a persistent shell process
self.process = await asyncio.create_subprocess_exec(
*self.shell_command, stdin=PIPE, stdout=PIPE, stderr=STDOUT, executable="bash"
*self.shell_command, stdin=PIPE, stdout=PIPE, stderr=STDOUT, executable="bash", env=os.environ.copy()
)
await self._check_state()
@ -150,6 +151,7 @@ class Bash(Terminal):
def __init__(self):
"""init"""
os.environ["SWE_CMD_WORK_DIR"] = str(DEFAULT_WORKSPACE_ROOT / "swe_agent_workdir")
super().__init__()
self.start_flag = False

View file

@ -16,4 +16,9 @@ source $REPO_ROOT_DIR/metagpt/tools/swe_agent_commands/defaults.sh
source $REPO_ROOT_DIR/metagpt/tools/swe_agent_commands/search.sh
source $REPO_ROOT_DIR/metagpt/tools/swe_agent_commands/edit_linting.sh
export SWE_CMD_WORK_DIR="$REPO_ROOT_DIR/workspace/swe_agent_workdir"
echo "SWE_CMD_WORK_DIR: $SWE_CMD_WORK_DIR"
# 检查 SWE_CMD_WORK_DIR 路径是否已存在,不存在则创建
if [ ! -d "$SWE_CMD_WORK_DIR" ]; then
mkdir -p $SWE_CMD_WORK_DIR
fi