使用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.0In 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
相关产品推荐
相关产品推荐

