langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
50.05k stars 7.15k forks source link

Runtime Error occurs when running `poetry shell` #6001

Closed lepangdan closed 3 months ago

lepangdan commented 3 months ago

Self Checks

Dify version

0.6.11

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Runtime Error occurs when running poetry shell in api/readme.md.

Dify API service uses Poetry to manage dependencies. You can execute poetry shell to activate the environment.

✔️ Expected Behavior

The thing is ok.

❌ Actual Behavior

/dify/api$ poetry shell

RuntimeError

The Poetry configuration is invalid:

dosubot[bot] commented 3 months ago

Hello, @lepangdan! I'm here to help you with bug reports, answer your questions, and guide you on becoming a contributor. Let's get your issue sorted while we wait for a human maintainer.

To resolve the Runtime Error related to the Poetry configuration when running poetry shell in the dify/api directory, follow these steps:

  1. Start the Docker Compose Stack: Ensure that the necessary middleware (PostgreSQL, Redis, and Weaviate) is running.

    cd ../docker
    docker compose -f docker-compose.middleware.yaml -p dify up -d
    cd ../api
  2. Copy and Configure Environment Variables: Copy .env.example to .env and generate a SECRET_KEY.

    cp .env.example .env
    sed -i "/^SECRET_KEY=/c\SECRET_KEY=$(openssl rand -base64 42)" .env  # For Linux
    secret_key=$(openssl rand -base64 42)
    sed -i '' "/^SECRET_KEY=/c\\
    SECRET_KEY=${secret_key}" .env  # For Mac
  3. Create and Activate the Environment: Use Poetry to manage dependencies and activate the environment.

    poetry env use 3.10
    poetry install
  4. Install Dependencies: If dependencies are missing from pyproject.toml, install them from requirements.txt and requirements-dev.txt.

    poetry shell
    poetry add $(cat requirements.txt)
    poetry add $(cat requirements-dev.txt) --group dev
  5. Run Database Migrations: Migrate the database to the latest version.

    poetry run python -m flask db upgrade
  6. Start the Backend: Run the backend service.

    poetry run python -m flask run --host 0.0.0.0 --port=5001 --debug
  7. Check Poetry Configuration: Ensure your poetry.toml file in the dify/api directory is correctly configured.

    [virtualenvs]
    in-project = true
    create = true
    prefer-active-python = true

By following these steps, you should be able to resolve the Runtime Error related to the Poetry configuration when running poetry shell in the dify/api directory [1][2][3][4].

To continue talking to Dosu, mention @dosu.

crazywoola commented 3 months ago

Please google how to use poetry instead of submitting a bug report.

lepangdan commented 3 months ago

Please google how to use poetry instead of submitting a bug report.

As a developer of the open-source repository, you have the authority to close an issue directly or to simply overlook it if you see fit. However, rather than suggesting non-informative responses and discouraging users from reporting issues after they have strictly adhered to the instructions in the provided README.

uply23333 commented 3 months ago

Upgrade poetry from 1.7.x to 1.8.x work for me.