Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix: Avoid bash backtick eval in runtime commands. (#2180)

Leo78e003caf651
diff --git a/opendevin/runtime/server/runtime.py b/opendevin/runtime/server/runtime.py
index 22ab8b76cd..44bd03cb14 100644
--- a/opendevin/runtime/server/runtime.py
+++ b/opendevin/runtime/server/runtime.py
@@ -49,16 +49,13 @@ class ServerRuntime(Runtime):
async def run_ipython(self, action: IPythonRunCellAction) -> Observation:
obs = self._run_command(
- ('cat > /tmp/opendevin_jupyter_temp.py <<EOL\n' f'{action.code}\n' 'EOL'),
+ ("cat > /tmp/opendevin_jupyter_temp.py <<'EOL'\n" f'{action.code}\n' 'EOL'),
background=False,
)
# run the code
obs = self._run_command(
- (
- 'export JUPYTER_PWD=$(pwd) && cat /tmp/opendevin_jupyter_temp.py | execute_cli'
- ),
- background=False,
+ ('cat /tmp/opendevin_jupyter_temp.py | execute_cli'), background=False
)
output = obs.content
if 'pip install' in action.code and 'Successfully installed' in output:
@@ -70,7 +67,7 @@ class ServerRuntime(Runtime):
):
obs = self._run_command(
(
- 'cat > /tmp/opendevin_jupyter_temp.py <<EOL\n'
+ "cat > /tmp/opendevin_jupyter_temp.py <<'EOL'\n"
f'{restart_kernel}\n'
'EOL'
),
@@ -91,7 +88,7 @@ class ServerRuntime(Runtime):
if action.kernel_init_code:
obs = self._run_command(
(
- f'cat > /tmp/opendevin_jupyter_init.py <<EOL\n'
+ f"cat > /tmp/opendevin_jupyter_init.py <<'EOL'\n"
f'{action.kernel_init_code}\n'
'EOL'
),