No such file or directory (os error 2) - Codex
Quick fix
将 config.toml 中的 model_catalog_json 绝对路径修改为相对路径 cc-switch-model-catalog.json,或升级 cc-switch。
Symptom
Section titled “Symptom”Error loading configuration: No such file or directory (os error 2)在 Windows 宿主机上运行 cc-switch 并为 WSL 环境中的 Codex 配置第三方供应商(如 DeepSeek)时,cc-switch 会在 config.toml 中自动生成 Windows UNC 格式的绝对路径(例如 \\wsl.localhost\Ubuntu\home\user\.codex\cc-switch-model-catalog.json)。
由于 WSL 的 Linux 系统调用无法解析这种 Windows UNC 路径,导致 Codex 启动时找不到模型目录文件,从而抛出 os error 2 错误。
升级 cc-switch 至包含 #3614 修复的版本,该版本会自动写入相对文件名。
或者手动编辑 WSL 中的 Codex 配置文件,将 model_catalog_json 的值修改为相对路径。
~/.codex/config.toml model_catalog_json = '\\wsl.localhost\Ubuntu-24.04\home\xxxxx\.codex\cc-switch-model-catalog.json'model_catalog_json = 'cc-switch-model-catalog.json'
Affected Versions
Section titled “Affected Versions”ToolCodex
Version未知
PlatformsWindows
Source Issues
Section titled “Source Issues”本页汇总自 2 个真实 issue
- 为什么 cc-switch 会生成 \\wsl.localhost 开头的路径?
- 因为 cc-switch 运行在 Windows 宿主机上,默认获取的是 Windows 视角的 WSL 路径(UNC 格式),而 WSL 内的 Linux 环境无法直接读取该格式的路径。
- 修改为相对路径后 Codex 能找到文件吗?
- 可以。Codex CLI 会相对于配置文件所在的目录来解析 model_catalog_json 的相对路径,因此直接使用 cc-switch-model-catalog.json 即可正常工作。
这是一个非官方社区 wiki,与 cc-switch 作者及项目本身无隶属关系。内容整理自项目公开的 GitHub issues。本站不分发任何软件。