nofx icon indicating copy to clipboard operation
nofx copied to clipboard

[BUG] 初始化数据库失败

Open JoshuaShuo opened this issue 1 year ago • 4 comments

无法配置数据库,程序启动时会创建名为config.db的文件夹,而不是名为config.db的文件,手动创建后仍然无法加载

nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: adaptive (adaptive.txt) nofx-trading | ╔════════════════════════════════════════════════════════════╗ nofx-trading | ║ 🤖 AI多模型交易系统 - 支持 DeepSeek & Qwen ║ nofx-trading | ╚════════════════════════════════════════════════════════════╝ nofx-trading | nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: default (default.txt) nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: nof1 (nof1.txt) nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: taro_long_prompts (taro_long_prompts.txt) nofx-trading | 2025/11/04 19:31:23 ✓ 已加载 4 个系统提示词模板 nofx-trading | 2025/11/04 19:31:23 📋 初始化配置数据库: config.db nofx-trading | 2025/11/04 19:31:23 ❌ 初始化数据库失败: 创建表失败: 执行SQL失败 [CREATE TABLE IF NOT EXISTS ai_models ( nofx-trading | id TEXT PRIMARY KEY, nofx-trading | user_id TEXT NOT NULL DEFAULT 'default', nofx-trading | name TEXT NOT NULL, nofx-trading | provider TEXT NOT NULL, nofx-trading | enabled BOOLEAN DEFAULT 0, nofx-trading | api_key TEXT DEFAULT '', nofx-trading | created_at DATETIME DEFAULT CURRENT_TIMESTAMP, nofx-trading | updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, nofx-trading | FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE nofx-trading | )]: unable to open database file: is a directory

JoshuaShuo avatar Nov 04 '25 11:11 JoshuaShuo

手动删除config.db目录即可,使用touch config.db创建一个空文件。 在 docker-compose.yml 中有这个挂载配置: volumes: - ./config.db:/app/config.db

Docker 的行为:

  • 如果宿主机上的 ./config.db 路径不存在
  • Docker 会自动创建一个目录(而不是文件)

1420970597 avatar Nov 04 '25 12:11 1420970597

在 compose 文件所在目录执行

ls -ld ./config.db

如果是目录:

[ -d ./config.db ] && rm -rf ./config.db

创建空文件

touch ./config.db

给合适权限(按需调整)

chmod 664 ./config.db

Peng1211 avatar Nov 04 '25 12:11 Peng1211

在 compose 文件所在目录执行

ls -ld ./config.db

如果是目录:

[ -d ./config.db ] && rm -rf ./config.db

创建空文件

touch ./config.db

给合适权限(按需调整)

chmod 664 ./config.db

我按你说的这样做了,报错 [+] Running 2/3 ✔ nofx-nofx Built 0.0s ✔ nofx-nofx-frontend Built 0.0s ⠋ Container nofx-trading Starting 0.1s Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/opt/1panel/docker/compose/nofx/nofx/config.db" to rootfs at "/app/config.db": mount src=/opt/1panel/docker/compose/nofx/nofx/config.db, dst=/app/config.db, dstFd=/proc/thread-self/fd/8, flags=MS_BIND|MS_REC: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

rizxfrog avatar Nov 04 '25 14:11 rizxfrog

无法配置数据库,程序启动时会创建名为config.db的文件夹,而不是名为config.db的文件,手动创建后仍然无法加载

nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: adaptive (adaptive.txt) nofx-trading | ╔════════════════════════════════════════════════════════════╗ nofx-trading | ║ 🤖 AI多模型交易系统 - 支持 DeepSeek & Qwen ║ nofx-trading | ╚════════════════════════════════════════════════════════════╝ nofx-trading | nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: default (default.txt) nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: nof1 (nof1.txt) nofx-trading | 2025/11/04 19:31:23 📄 加载提示词模板: taro_long_prompts (taro_long_prompts.txt) nofx-trading | 2025/11/04 19:31:23 ✓ 已加载 4 个系统提示词模板 nofx-trading | 2025/11/04 19:31:23 📋 初始化配置数据库: config.db nofx-trading | 2025/11/04 19:31:23 ❌ 初始化数据库失败: 创建表失败: 执行SQL失败 [CREATE TABLE IF NOT EXISTS ai_models ( nofx-trading | id TEXT PRIMARY KEY, nofx-trading | user_id TEXT NOT NULL DEFAULT 'default', nofx-trading | name TEXT NOT NULL, nofx-trading | provider TEXT NOT NULL, nofx-trading | enabled BOOLEAN DEFAULT 0, nofx-trading | api_key TEXT DEFAULT '', nofx-trading | created_at DATETIME DEFAULT CURRENT_TIMESTAMP, nofx-trading | updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, nofx-trading | FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE nofx-trading | )]: unable to open database file: is a directory

你好。我也是这个问题。请问怎么解决的啊

samilyang avatar Nov 04 '25 16:11 samilyang