When entering the container to perform the database upgrade operation, an issue occurred.

用户在 Dify 1.15.0 自托管(Docker)环境中,进入容器后执行数据库升级命令时触发。

When entering the container to perform the database upgrade operation, an issue occurred.

When entering the container to perform the database upgrade operation, an issue occurred.

快速结论:该报错通常出现在 Dify 自托管 Docker 环境下执行数据库升级操作时,优先排查是否缺少 dify-agent 依赖包或文件路径不正确。

问题场景

用户在 Dify 1.15.0 自托管(Docker)环境中,进入容器后执行数据库升级命令时触发。

报错原文

error: Failed to generate package metadata for `dify-agent==0.1.0 @ editable+../dify-agent`
  Caused by: Distribution not found at: file:///app/dify-agent

原因分析

可能原因:Dify 容器内的 dify-agent 包以可编辑模式(editable install)安装,但实际路径 /app/dify-agent 不存在或挂载丢失,导致 Python 打包工具无法生成元数据,从而阻塞数据库升级流程。

环境排查

  • 确认 Dify 版本为 1.15.0
  • 确认 .env 文件中 MIGRATION_ENABLED 是否设置为 true(默认值)
  • 确认 Docker Compose 配置中 dify-agent 目录是否正确挂载
  • 检查容器内 /app/dify-agent 是否存在

解决步骤

  1. 重新启动容器,让自动迁移机制先运行:docker compose down && docker compose up -d
  2. 验证迁移日志:docker compose logs api | grep -i migration
  3. 如果自动迁移已成功,数据库升级命令应可正常执行;若仍失败,请优先检查 dify-agent 包的安装路径和文件完整性
  4. 如需手动执行数据库升级,请确保按正确顺序运行:docker compose exec api flask upgrade-db,随后按需运行 docker compose exec api flask backfill-plugin-auto-upgrade

验证方法

重新执行数据库升级命令,不再出现 Distribution not found 错误即表示问题已解决;也可通过查看容器日志确认迁移任务正常完成。

参考来源

langgenius/dify #38090

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 10242

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注