All-Hands-AI / OpenHands

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

Directory './frontend/dist' does not exist #1132

Closed paopa closed 7 months ago

paopa commented 7 months ago

Describe the bug

I'm new to this project and followed the Development Guide to run Open Devin. however, it lacks the frontend/dist folder when starting the backend service. and, the root cause is here.

# server/listen.py
app.mount('/', StaticFiles(directory='./frontend/dist'), name='dist')

I checked the Makefile, it seems didn't execute npm run build in the install-frontend-dependencies command. a workaround is executing the command to build dist tho. but, I'm not sure it will be as the teams' expectation for development. according to Getting Started with the OpenDevin Frontend, the build command seems for building the app for production. so, not sure if putting this command to the install-frontend-dependencies command whether a good idea.

Setup and configuration

Current version:

commit 2491a3524e9b112ef9fe4d5059161ec3f85cbc69 (HEAD -> main, upstream/main, origin/main, origin/HEAD)
Author: Edwards.Arno <138990495+Umpire2018@users.noreply.github.com>
Date:   Mon Apr 15 22:14:37 2024 +0800

    feat: add `question.md` template for community Q&A (#1115)

    * feat: add `question.md` template for community Q&A

    * Update .github/ISSUE_TEMPLATE/question.md

    ---------

    Co-authored-by: Robert Brennan <accounts@rbren.io>

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

LLM_MODEL="gpt-3.5-turbo-1106"
LLM_API_KEY="***"
LLM_EMBEDDING_MODEL=""
WORKSPACE_DIR="./workspace"

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

Commands I ran to install and run OpenDevin: I followed this instructions to install

Steps to Reproduce:

  1. make build
  2. make setup-config
  3. make run

Logs, error messages, and screenshots:

Running the app...
Starting backend server...
Waiting for the backend to start...
ERROR:root:  File "/Users/workspace/Projects/paooap/open-devin/.venv/bin/uvicorn", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/uvicorn/main.py", line 409, in main
    run(
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/uvicorn/main.py", line 575, in run
    server.run()
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 69, in serve
    await self._serve(sockets)
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 76, in _serve
    config.load()
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/uvicorn/config.py", line 433, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in impo
rt_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/workspace/Projects/paooap/open-devin/opendevin/server/listen.py", line 139, in <module>
    app.mount('/', StaticFiles(directory='./frontend/dist'), name='dist')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/workspace/Projects/paooap/open-devin/.venv/lib/python3.12/site-packages/starlette/staticfiles.py", line 59, in __init__
    raise RuntimeError(f"Directory '{directory}' does not exist")

ERROR:root:<class 'RuntimeError'>: Directory './frontend/dist' does not exist
paopa commented 7 months ago

if the team could provide me with suggestions to address this issue, I'm willing to do this issue.

Sparkier commented 7 months ago

I ran into the same issue. As a hot fix, you can run npm run build in the frontend directory. This should be run in make build, however.

Sparkier commented 7 months ago

Actually, this is a bigger problem since this mount should only happen for the Docker setup, not for the dev setup.

foragerr commented 7 months ago

Are you saying in the dev setup the frontend should be served by vite and not fastapi? @Sparkier

Sparkier commented 7 months ago

Most likely yes. If we serve it like we do now we're loosing all the nice dev features like hot reload etc.

foragerr commented 7 months ago

@Sparkier review please: https://github.com/OpenDevin/OpenDevin/pull/1137 This isn't ideal in that, in a dev setup, front end will be served on both fastapi (a static snapshot) and vite (hot reloads) but it gets past the dist not found issue.

Sparkier commented 7 months ago

Serving on both endpoints is fine I think.

riverind commented 7 months ago

how to solve it?

enyst commented 7 months ago

@riverind It should be fixed now in the main repository. Please update your repo ( git pull) and re-run the installation steps.

riverind commented 7 months ago

@riverind It should be fixed now in the main repository. Please update your repo ( git pull) and re-run the installation steps.

thx for your suggestion however, new error occur " auth.py:18 - Error decoding token: Not enough segments"

isweir commented 6 months ago

@riverind It should be fixed now in the main repository. Please update your repo ( git pull) and re-run the installation steps.

no it is not resolve, i ran into this error just today

isweir commented 6 months ago

make run Running the app... Starting backend server... Waiting for the backend to start... ERROR:root: File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/bin/uvicorn", line 8, in sys.exit(main()) ^^^^^^ File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/uvicorn/main.py", line 409, in main run( File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/uvicorn/main.py", line 575, in run server.run() File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/uvicorn/server.py", line 65, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/uvicorn/server.py", line 69, in serve await self._serve(sockets) File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/uvicorn/server.py", line 76, in _serve config.load() File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/uvicorn/config.py", line 433, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/uvicorn/importer.py", line 19, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/mnt/c/Users/Wei Lin/OpenDevin/opendevin/server/listen.py", line 343, in app.mount('/', StaticFiles(directory='./frontend/dist'), name='dist') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wei/.cache/pypoetry/virtualenvs/opendevin-W7PrGhyP-py3.11/lib/python3.11/site-packages/starlette/staticfiles.py", line 59, in init raise RuntimeError(f"Directory '{directory}' does not exist")

ERROR:root:<class 'RuntimeError'>: Directory './frontend/dist' does not exist 00:21:14 - opendevin:INFO: manager.py:46 - Closing 0 agent(s)... 00:21:14 - opendevin:INFO: manager.py:43 - Saving sessions... 00:21:14 - opendevin:INFO: msg_stack.py:41 - Saving messages...

av commented 1 month ago

To anybody running into this issue - check if you're running with a custom --workdir.

OpenHands needs to be served from the original workdir and a pointer to the directory with code must be done via WORKSPACE_MOUNT_PATH env var.