Codex with ollama won’t launch

用户尝试在 Linux 系统上使用 Ollama 0.24.0 启动 Codex CLI(命令为 ollama launch codex )或启动 Codex App(命令为 ollama launch codex-app )。Ollama 会自动在配置文件 ~/.codex/config.toml

快速结论:当 Ollama 0.24.0 通过 ollama launch codex 命令启动 Codex CLI 或 Codex App 时,Ollama 会向 ~/.codex/config.toml 中写入不被 Codex 0.134+ 支持的旧版(legacy)profile 配置,导致 Codex 启动失败,报错提示 legacy profile ... is no longer supported。核心原因在于 Ollama 的 codex 集成尚未适配 Codex 的 profile v2 配置格式。

问题场景

用户尝试在 Linux 系统上使用 Ollama 0.24.0 启动 Codex CLI(命令为 ollama launch codex)或启动 Codex App(命令为 ollama launch codex-app)。Ollama 会自动在配置文件 ~/.codex/config.toml 中写入 [profiles.ollama-launch]profile = "ollama-launch" 等旧版配置块,而 Codex 0.134.0 以上的新版不再支持这种 profile 定义方式。

报错原文

Error loading config.toml: --profile `ollama-launch` cannot be used while /home/cognitron/.codex/config.toml contains legacy `profile = "ollama-launch"` or `[profiles.ollama-launch]` config; move those settings into /home/cognitron/.codex/ollama-launch.config.toml and remove the legacy profile selector/table. See https://developers.openai.com/codex/config-advanced#profiles for more information.
Error: exit status 1

或(Codex App 场景):

Error starting chat
failed to resolve feature override precedence: legacy `profile = "ollama-launch-codex-app"` config is no longer supported; use `--profile ollama-launch-codex-app` with `ollama-launch-codex-app.config.toml` instead

原因分析

可能原因:Ollama 0.24.0 版本的 ollama launch codex 命令依然按照 Codex 旧版的配置方式,将 profile 相关的配置(例如 [profiles.ollama-launch]profile = "ollama-launch")直接写到 ~/.codex/config.toml 的顶层。而 Codex 从 0.134.0 版本开始,不再支持在 config.toml 内直接包含 [profiles.<name>] 键表或 profile = "<name>" 字段。新规范要求将 profile 设置写入独立的配置文件,例如 ~/.codex/ollama-launch.config.toml,并在启动时使用 --profile ollama-launch 参数。

在 Issue 评论中确认,即使手动删除 config.toml 中的旧版 profile 配置块,Ollama 的 ollama launch codex 命令在下次执行时又会自动重新生成这些内容,导致问题持续存在。

用户提交了修复 PR(#16351),该问题在 Ollama 0.30.0 版本已被修复。

环境排查

  • 确认 Ollama 版本是否为 0.24.0(该版本已知有此问题)。
  • 确认 Codex CLI 或 Codex App 的版本是否在 0.134.0 或以上。
  • 检查 ~/.codex/config.toml 文件中是否存在 [profiles.ollama-launch]profile = "ollama-launch" 或类似的旧版配置项。
  • 检查 ~/.codex/ 目录下是否存在独立的 profile 配置文件(如 ollama-launch.config.toml)。

解决步骤

  1. 方案一(推荐):升级 Ollama 至 v0.30.0 或更高版本。 Issue 评论和 PR 确认该问题在 v0.30.0 中已修复。升级后,ollama launch codex 会按照新的 Codex profile v2 规范生成正确的配置,问题自动解决。
  2. 方案二(临时规避,可优先尝试):手动清理旧配置,并使用 npm install -g @openai/codex@0.133.0 降级 Codex CLI 至兼容的旧版(0.133.0)。此方案不依赖 Ollama 修复,可等待 Ollama 后续更新后再升级 Codex。
  3. 方案三(手动配置,绕过 ollama launch):
    1. 打开 ~/.codex/config.toml,删除所有 [profiles.ollama-launch]profile = "ollama-launch" 以及类似的 legacy 配置行。注意:保留 [model_providers.ollama-launch] 节,不要删除。
    2. 手动创建 ~/.codex/ollama-launch.config.toml 文件,写入如下内容,并将 <your users path> 替换为你的实际用户路径:
      model = "gemma4"
      model_provider = "ollama-launch-codex-app"
      model_catalog_json = "/<your users path>/.codex/ollama-launch-models.json"
      openai_base_url = "http://127.0.0.1:11434/v1/"
    3. ~/.codex/config.toml[model_providers] 节附近,确保 [model_providers.ollama-launch-codex-app] 配置正确。
    4. 直接启动 Codex CLI 或 Codex App(使用系统命令,如 codex 或打开桌面应用),不要使用 ollama launch 命令。

验证方法

启动 Codex CLI 或 Codex App 后,观察是否不再出现上述错误提示,且能正常加载模型并进入对话界面。如果是降级方案,可执行 codex --version 确认版本号为 0.133.0。如果是升级方案,可执行 ollama --version 确认版本号 ≥ 0.30.0。

参考来源

ollama/ollama #16348

GamsGo AI

AI 工具推荐

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

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

了解 GamsGo AI

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

这个方案解决了吗?

celebrityanime
celebrityanime
文章: 15411

发表回复

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