All-Hands-AI / OpenHands

🙌 OpenHands: Code Less, Make More
https://all-hands.dev
MIT License
36.43k stars 4.14k forks source link

OpenDevin can't `apt install` #550

Closed robshox closed 7 months ago

robshox commented 7 months ago

I'm getting these kinds of 127 errors

Command sudo apt update && sudo apt install nodejs npm -y executed with exit code 127.

ODevin Can write to the file system on my machine but anything got to do with downloading or running packages I believe in the sandbox won't work. I think this has got to do with the fact I'm on Windows but I thought the backend had it's own Docker setup with Linux.

rbren commented 7 months ago

Hmm...this should be solved since we started running Devin as root.

Are there any error messages besides this?

Also--it would be helpful if you could fill out the issue template

andrescevp commented 7 months ago

I was playing a bit eith this and getting the same error, I am not sure who is the responsible to run the command, the planner or the code agent, I had modified the templates to set examples and explicit instructions to use sudo when system packages installation is required, but not luck. I am not sure if it would be better to just set the user of the sandbox as superuser so the prompt can be simpler assuming that capability comes from the system.

somehow this approach feels better to me because if I want to give privileges to the ai assitant it should come from the system as an permission or so... but having an assitant that can become super user when it wants... it is kind of dangerous.

AmerDinar commented 7 months ago

same issue.

enyst commented 7 months ago

@andrescevp @AmerDinar Are you also running on Windows like the OP?

andrescevp commented 7 months ago

Using it with Ubuntu

andrewparry commented 7 months ago

Maybe this helps? This is the error message I observe with Ubuntu.

ACTION:
CmdRunAction(command='sudo apt-get update && sudo apt-get install -y cppcheck', background=False, action=<ActionType.RUN: 'run'>)
13:02:00 - opendevin:ERROR: sandbox.py:227 - Command timed out, killing process...
13:04:00 - opendevin:ERROR: sandbox.py:227 - Command timed out, killing process...

OBSERVATION:
Command: "sudo apt-get update && sudo apt-get install -y cppcheck" timed out. Sending SIGINT to the process: sudo: unable to resolve host opendevin_sandbox: Temporary failure in name resolution
[sudo] password for opendevin: 
sudo: a password is required
enyst commented 7 months ago

A fix for that has just been merged, @andrewparry , please update.

andrewparry commented 7 months ago

Ok updated, I see the command now being run without sudo, but fall into this error, from Opendevin terminal:

$ apt update && apt install clang-tidy -y
Reading package lists... 0Reading package lists... 0Reading package lists... 3Reading package lists... Done
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)

Out of interest

parallels@ubuntu-linux-22-04-02-desktop:~/OpenDevin$ ls -l /var/lib/apt/lists
total 183932
...
drwx------ 2 _apt root    12288 Apr  8 15:56 partial
...
kroggen commented 7 months ago

Same error for me, trying to install sqlite3:

ACTION:
CmdRunAction(command='apt update && apt install sqlite3 -y', background=False, action=<ActionType.RUN: 'run'>)

OBSERVATION:
Reading package lists... Done
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
hcossio commented 7 months ago

@andrewparry @kroggen Apparently this is a Docker problem. I'm having some success editing the docker file and adding:

ARG SSL_KEYSTORE_PASSWORD USER root USER 1001

Looks like:

FROM ubuntu:22.04 ARG SSL_KEYSTORE_PASSWORD USER root '#' install basic packages RUN apt-get update && apt-get install -y \ curl \ wget \ git \ vim \ nano \ unzip \ zip \ python3 \ python3-pip \ python3-venv \ python3-dev \ build-essential \ openssh-server \ sudo \ && rm -rf /var/lib/apt/lists/* USER 1001 RUN service ssh start

Also, adding in sandbox.py:

USER_ID = 1001

before commenting out:

if config.get_or_none('SANDBOX_USER_ID') is not None: USER_ID = int(config.get_or_default('SANDBOX_USER_ID', '')) elif hasattr(os, 'getuid'): USER_ID = os.getuid()

andrescevp commented 7 months ago

working for me on Ubuntu, thanks guys!

R-Dson commented 7 months ago

@andrewparry @kroggen Apparently this is a Docker problem. I'm having some success editing the docker file and adding:

ARG SSL_KEYSTORE_PASSWORD USER root USER 1001

Looks like:

FROM ubuntu:22.04 ARG SSL_KEYSTORE_PASSWORD USER root '#' install basic packages RUN apt-get update && apt-get install -y curl wget git vim nano unzip zip python3 python3-pip python3-venv python3-dev build-essential openssh-server sudo && rm -rf /var/lib/apt/lists/* USER 1001 RUN service ssh start

Also, adding in sandbox.py:

USER_ID = 1001

before commenting out:

if config.get_or_none('SANDBOX_USER_ID') is not None: USER_ID = int(config.get_or_default('SANDBOX_USER_ID', '')) elif hasattr(os, 'getuid'): USER_ID = os.getuid()

Thanks, that fixed it for me, but it was exec_box.py and not sandbox.py.

rbren commented 7 months ago

I believe this is fixed now that everything is running in a consistent sandbox with RUN_AS_DEVIN=false