You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Phoenix 1.7-rc创建的项目编译失败问题排查

问题:Phoenix 1.7-rc 伞项目依赖冲突编译失败

环境与操作

  • Elixir 1.14.1 + Erlang/OTP 24
  • 安装 Phoenix 1.7-rc 后,执行 mix phx.new 创建伞项目(umbrella),编译时出现依赖冲突错误

报错信息

Unchecked dependencies for environment dev:

  • phoenix (Hex package)
    the dependency phoenix 1.7.0-rc.0

    In apps/trial_web/mix.exs:
    {:phoenix, "~> 1.7.0-rc.0", [env: :prod, repo: "hexpm", hex: "phoenix", override: true]}

    does not match the requirement specified

    In deps/phoenix_live_view/mix.exs:
    {:phoenix, "~> 1.6.15 or ~> 1.7.0", [env: :prod, hex: "phoenix", repo: "hexpm", optional: false]}

    Ensure they match or specify one of the above in your deps and set "override: true"
    ** (Mix) Can't continue due to errors on dependencies

子项目依赖配置(apps/trial_web/mix.exs)

{:phoenix, "~> 1.7.0-rc.0", override: true},

疑问

已经在子项目的依赖中设置了 override: true,为什么依然触发依赖版本不匹配的报错?

排查与解决过程

  • 尝试1:移除根目录 mix.exs 中的 phoenix_live_view 依赖后,项目可以正常编译,但无法在根目录对 .heex 文件执行 mix format,不符合需求。
  • 最终解决:由于根目录格式化 HEEx 文件需要依赖 phoenix_live_view,而该依赖对 Phoenix 有版本要求,因此在根目录的 mix.exs 中也添加 Phoenix 依赖并设置 override: true,示例配置如下:
{:phoenix, "~> 1.7.0-rc.0", override: true},
{:phoenix_live_view, "~> 0.18.0"}, # 根据实际版本调整

添加后项目成功编译,同时根目录也能正常执行 mix format 处理 HEEx 文件。

内容的提问来源于stack exchange,提问作者101V

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 23:35:50