OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Errno 2] No such file or directory:

Open katmai opened this issue 1 year ago • 2 comments

Describe the bug

there's a consistent problem with file operations, where it keeps going on weird paths. it can't either read or write, sometimes it gets it right, sometimes it doesn't.

as far as i could tell there seems to be an instance of /workspace/ in "/home/atlas/OpenDevin/opendevin/action/fileop.py"

but im not sure if it's used by the LLM. shouldn't workspace pathing be consistent ?

Setup and configuration

Current version:

commit e0c7492609bf8ebdbd7270c9e9261bf2944f3bc6 (HEAD -> main, origin/main, origin/HEAD)
Author: Boxuan Li <[email protected]>
Date:   Fri Apr 12 12:01:52 2024 -0700

    Traffic Control: Add new config MAX_CHARS (#1015)

    * Add new config MAX_CHARS

    * Fix mypy linting issues

My config.toml and environment vars (be sure to redact API keys):

LLM_API_KEY="ollama"
LLM_MODEL="ollama/atlas:002"
LLM_EMBEDDING_MODEL="local"
LLM_BASE_URL="http://localhost:11434"
WORKSPACE_DIR="./workspace/"
SANDBOX_TYPE="exec"

My model and agent (you can see these settings in the UI):

  • Model:
  • Agent:

Commands I ran to install and run OpenDevin:

Steps to Reproduce:

  1. run opendevin.
  2. run into a bunch of file operations path issues.

Logs, error messages, and screenshots:

==============
STEP 9

PLAN:
write a bash script that prints hi

ACTION:
FileWriteAction(path='./workspace/memory.txt', content="I'm going to create a file called 'memory.txt' to store my thoughts.", action=<ActionType.WRITE: 'write'>)

ERROR:
[Errno 2] No such file or directory: './workspace/./workspace/memory.txt'
Traceback (most recent call last):
  File "/home/atlas/OpenDevin/opendevin/controller/agent_controller.py", line 186, in step
    if inspect.isawaitable(action.run(self)):
                           ^^^^^^^^^^^^^^^^
  File "/home/atlas/OpenDevin/opendevin/action/fileop.py", line 43, in run
    with open(whole_path, "w", encoding="utf-8") as file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: './workspace/./workspace/memory.txt'

OBSERVATION:
[Errno 2] No such file or directory: './workspace/./workspace/memory.txt'

Additional Context

katmai avatar Apr 12 '24 20:04 katmai

Not sure why LLM try to write a non exist file, but we can add some check here to make sure file exist. Will solve it later.

yufansong avatar Apr 13 '24 00:04 yufansong

Hmm--something is fishy here. Unclear why the LLM decided that it needed to add ./workspace

rbren avatar Apr 14 '24 13:04 rbren

@katmai, Could you reproduce this again?

SmartManoj avatar Apr 16 '24 14:04 SmartManoj

@katmai, Could you reproduce this again?

not right now. maybe in the future. i'm sure you guys got this.

katmai avatar Apr 16 '24 14:04 katmai

According to the discussion in comments, decide to close this issue. We should put more efforts on why llm output the wrong file path.

yufansong avatar Apr 16 '24 17:04 yufansong

@katmai do you use ollama/atlas:002 model? Is this a local model? BTW, can you provide more details abotu what you did before the step 9?

yufansong avatar Apr 16 '24 18:04 yufansong

@katmai do you use ollama/atlas:002 model? Is this a local model? BTW, can you provide more details abotu what you did before the step 9?

yes, atlas:003 is my local model.

this was my prompt. cd ~/$OpenDevin/ && poetry run python opendevin/main.py -d ./workspace/ -t "create a script that says hi"

katmai avatar Apr 17 '24 01:04 katmai

I am getting same issue. Here is my config.toml:

LLM_API_KEY="anything"
LLM_MODEL="ollama/mistral"
LLM_EMBEDDING_MODEL="mistral"
LLM_BASE_URL="http://localhost:11434"
WORKSPACE_DIR="./workspace"
SANDBOX_TYPE="exec"

manjeetsingh53 avatar Apr 17 '24 14:04 manjeetsingh53

Could you provide the llm logs in logs/llm folder?

SmartManoj avatar Apr 17 '24 14:04 SmartManoj

@SmartManoj - Please see my logs attached. It looks like someone patched something, i am not sure what exactly. I am able to run it, but it's quite slow. I did following steps

git fetch
git pull
make build
make run

With local mistral model it's very very slow. In my case i asked it to generate a "write a python code to sum 2 numbers" image

I also tried using llama2. But slowness is same. logs.zip

manjeetsingh53 avatar Apr 17 '24 14:04 manjeetsingh53

error found in 24-04-17_16-08/prompt_007.log

Log parser

import os
from pprint import pprint
from pymsgbox import alert

a=r'logs\llm'
for folder in os.listdir(a):
    print(folder)
    folder_path = os.path.join(a,folder)
    for file in os.listdir(folder_path):
        print(file)

        if file.startswith("response") or file.startswith('prompt'):
            with open(os.path.join(folder_path,file)) as f:
                content = (f.read())
                if 'No such file or directory:' in content:
                    exec('content='+content)
                    # print(content)
                    print(content[0]['content'])
                    # alert('Please check the issue')
                    break
            print("---------------")

SmartManoj avatar Apr 17 '24 14:04 SmartManoj

  {
    "action": "think",
    "args": {
      "thought": "Let's check if 'sum.py' file exists in the current directory."
    },
    "message": "Let's check if 'sum.py' file exists in the current directory."
  },
  {
    "observation": "null",
    "content": "",
    "extras": {},
    "message": ""
  },
  {
    "action": "read",
    "args": {
      "path": "./sum.py"
    },
    "message": "Reading file: ./sum.py"
  },
  {
    "observation": "error",
    "content": "[Errno 2] No such file or directory: '/mnt/d/ollama-experiment/Open Devin/OpenDevin/./sum.py'",
    "extras": {},
    "message": "Oops. Something went wrong: [Errno 2] No such file or directory: '/mnt/d/ollama-experiment/Open Devin/OpenDevin/./sum.py'"
  }

Instead of the ls command it used the read action. And, finally it created the file.

SmartManoj avatar Apr 17 '24 14:04 SmartManoj

@SmartManoj - Thanks for input. But i am still not able to understand why it's creating file outside "./workspace" directory.

manjeetsingh53 avatar Apr 17 '24 14:04 manjeetsingh53

How did you run?

SmartManoj avatar Apr 17 '24 14:04 SmartManoj

https://github.com/OpenDevin/OpenDevin/issues/1063#issuecomment-2061397693

manjeetsingh53 avatar Apr 17 '24 14:04 manjeetsingh53

workspace dir in config?

SmartManoj avatar Apr 18 '24 04:04 SmartManoj

@SmartManoj I don't see any workspace dir? Do i need to create it?

manjeetsingh53 avatar Apr 18 '24 09:04 manjeetsingh53

set WORKSPACE_MOUNT_PATH=/mnt/d/ollama-experiment/Open Devin/OpenDevin/workspace in config.toml If you run via docker, it will automatically set it.

SmartManoj avatar Apr 18 '24 09:04 SmartManoj

@SmartManoj - I am still fetching lot of issue in generating project using OpenDevin. I have been able to get it up and running, but it never works correctly, always ends up with some sort of error. Latest error i am encountering is

13:39:12 - opendevin:ERROR: agent_controller.py:175 - "'action' key is not found in action={'thought': 'What are the steps I need to take to create a simple webpage using React?'}"
13:39:12 - OBSERVATION
"'action' key is not found in action={'thought': 'What are the steps I need to take to create a simple webpage using React?'}"  

and

13:41:41 - opendevin:ERROR: agent_controller.py:175 - Invalid response: no JSON found
13:41:41 - OBSERVATION
Invalid response: no JSON found

manjeetsingh53 avatar Apr 18 '24 11:04 manjeetsingh53