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

cabal build失败提示(conflict: requires GHC2021),求解析与解决

解决Cabal依赖解析失败(GHC2021冲突)的问题

问题重现

执行cabal build myproject时出现依赖解析错误:

cabal build myproject
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] next goal: plutarch (user goal)
[__0] rejecting: plutarch-1.3.0 (conflict: requires GHC2021)
[__0] fail (backjumping, conflict set: plutarch)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: plutarch

当前环境信息:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.0.2
$ cabal --version
cabal-install version 3.4.0.0
compiled using version 3.4.0.0 of the Cabal library

cabal.project配置:

packages: myproject/

source-repository-package
    type: git
    location: https://github.com/Plutonomicon/plutarch-plutus.git
    tag: 01a67f56b2bf428538e92ed9ada0ce88d90ab636

错误原因

GHC2021是Haskell官方推出的统一语言标准,整合了常用的语言扩展集合。GHC 9.0.2不支持GHC2021,该标准从GHC 9.2版本开始正式支持。你要安装的plutarch-1.3.0版本明确要求使用GHC2021规范,当前GHC版本无法满足依赖要求,导致解析失败。

解决方案

方案1:升级GHC到9.2及以上版本

这是最直接的解决方式,升级后可满足plutarch对GHC2021的要求:

  • 使用ghcup工具安装兼容版本(例如9.2.8):
    ghcup install ghc 9.2.8
    
  • 切换到新安装的GHC版本:
    ghcup set ghc 9.2.8
    
  • 重新执行构建命令:
    cabal build myproject
    

方案2:指定兼容当前GHC版本的plutarch版本

如果暂时不想升级GHC,可强制使用不要求GHC2021的plutarch旧版本:

  1. 在cabal.project中添加版本约束:
    packages: myproject/
    
    constraints: plutarch < 1.3.0
    
    source-repository-package
        type: git
        location: https://github.com/Plutonomicon/plutarch-plutus.git
        tag: 01a67f56b2bf428538e92ed9ada0ce88d90ab636
    
  2. 或者替换source-repository-package的tag为plutarch 1.2.x系列对应的commit,确保该版本不依赖GHC2021。

内容的提问来源于stack exchange,提问作者Chris Stryczynski

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 02:30:57